line_push/node_modules/eslint-template-visitor/lib/match-keys.js
2022-07-17 13:16:16 +08:00

31 lines
575 B
JavaScript

const { KEYS, getKeys } = require('eslint-visitor-keys');
const ignoredKeys = new Set([
'start',
'end',
]);
const ignoredLiteralKeys = new Set([
'value',
'regex',
]);
const getMatchKeys = node => {
const keys = getKeys(node).filter(key => !ignoredKeys.has(key));
const visitorKeys = KEYS[node.type];
let equalityKeys = keys.filter(key => !visitorKeys.includes(key));
if (node.type === 'Literal') {
equalityKeys = equalityKeys.filter(key => !ignoredLiteralKeys.has(key));
}
return {
visitorKeys,
equalityKeys,
};
};
module.exports = {
getMatchKeys,
};