Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function runRule(code, eslint, sourceCode) {
// Run the ESLint rule on the AST of the provided code.
// Reference: http://eslint.org/docs/developer-guide/nodejs-api
const ast = parseNoPatch(code, {
sourceType: 'module',
});
const results = eslint.verify(new sourceCode(code, ast), {
env: {es6: true},
parserOptions: {
ecmaVersion: 8,
sourceType: 'module',
ecmaFeatures: {experimentalObjectRestSpread: true},
},
rules: {
astExplorerRule: 2,
},
});
return formatResults(results);
}
parse(code) {
return parseNoPatch(code, { sourceType: 'module' });
},
});