Skip to content

Conversation

@florianehmke
Copy link
Contributor

This PR adds a new rule to prohibit certain file name patterns.

I think this is a good addition to this plugin. I often see inconsistent usage of file patterns like the ones used in the tests. Instead of documenting such things I want an eslint rule that takes care of that for me.

Let me know what you think and if I should change something.

@dukeluo
Copy link
Owner

dukeluo commented Oct 27, 2022

@florianehmke Thanks for the new rule! It's a greate idea!

},
{
type: 'object',
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this new rule does not need the rule configuration object, I think { type: 'object', } is unnecessary.


if (useInsteadPattern) {
message += ' Use a pattern like {{ useInsteadPattern }} instead.';
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ' Use a pattern like "{{ useInsteadPattern }}" instead.' will be better.

pattern: blackListPattern,
};
};

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can reuse the matchRule method with some changes to the params targetNaming and targetNamingPattern, just making them optional.

let message =
'The filename "{{path}}" matches the blacklisted "{{pattern}}" pattern.';

if (useInsteadPattern) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems useInsteadPattern is always given, I do not think it is necessary to protect it with if.

@florianehmke florianehmke requested a review from dukeluo October 31, 2022 07:43
Copy link
Owner

@dukeluo dukeluo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good!

@dukeluo dukeluo merged commit 58c644f into dukeluo:main Oct 31, 2022
@dukeluo
Copy link
Owner

dukeluo commented Oct 31, 2022

@florianehmke This PR is merged. This will be released over the weekend. Thanks!

@florianehmke
Copy link
Contributor Author

Thanks alot!

@dukeluo
Copy link
Owner

dukeluo commented Nov 5, 2022

The PR has been released in version 1.3.0. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants