Skip to content

Commit

Permalink
refactor: no need to process executeRuleWithContext when excluded
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite007 committed Dec 8, 2024
1 parent 754d50c commit 16e5ec1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/eslint-plugin/src/lib/rules/create-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ export const createRule: (
executor: Executor,
) => Rule.RuleModule = (ruleName, fileFilter, executor) => ({
create: (context) => {
const filename = context.filename ?? context.getFilename();
if (isExcluded(fileFilter, filename)) {
return {};
}

let isFirstRun = true;
let hasInternalError = false;
const executeRuleWithContext = (node: ExecutorNode) => {
const filename = context.filename ?? context.getFilename();
const sourceCode =
context.sourceCode?.text ?? context.getSourceCode().text;

if (isExcluded(fileFilter, filename)) {
return;
}

if (!hasInternalError) {
try {
// don't process special export `export const value = {n: 1};`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('create rule', () => {
expect(spy).toHaveBeenCalledTimes(2);
});

it.only('should NOT call the rule executor for any import or export types when filename is "sheriff.config.ts"', () => {
it('should NOT call the rule executor for any import or export types when filename is "sheriff.config.ts"', () => {
tester.run('test-rule', testRule, {
valid: [
{
Expand Down

0 comments on commit 16e5ec1

Please sign in to comment.