Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new rule to report anything that filename contains util #57

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

jpolavar
Copy link
Contributor

@jpolavar jpolavar commented Mar 12, 2024

Closes #56

image

@jpolavar jpolavar added the MINOR label Mar 12, 2024
@jpolavar jpolavar self-assigned this Mar 12, 2024
@jpolavar jpolavar requested a review from carlansley March 12, 2024 20:24
Copy link
Contributor

Choose a reason for hiding this comment

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

we should update ci.yml to the latest, i.e. node 20/21

package.json Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

might be worth doing another PR to update this repo to the latest stuff before adding this functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created new PR #59

errors: [{ message: `File name 'test-util.ts' contains banned 'util' pattern.` }],
},
{
filename: 'testUtil.ts',
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure these last two should be banned. I'm thinking the regex is more like [non-alphanumeric or start-of-line]util[non-alphanumeric or end-of-line]

We should also have tests for things in a util directory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/util/utility-test.ts should we report this as it is under util directory

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the /util/ part makes it problematic

src/no-util.ts Outdated
return {
Program() {
const filename = context.filename;
const utilRegex = /util/iu;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need this regex to be more sophisticated, e.g. electric-utility.ts shouldn't be banned, but something like electric-util.ts should be.

Copy link

❌ PR review status - reviewer has not approved

@carlansley
Copy link
Contributor

One other thing to think about is how this combines with the file-path-comment rule. e.g. what happens if we want to disable the no-util-rule? looking at the code it's going to report an error at the first line of the file, but to disable it we'd be breaking the file comment rule? Might want to experiment with this.

Copy link

Coverage after merging no-util-rule into main will be

96.79%▴ +0.09%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   file-path-comment.ts100%100%100%100%
   no-card-numbers.ts92.59%89.29%100%93.18%134–135, 137–138, 144–145
   no-util.ts100%100%100%100%
   no-uuid.ts92.31%87.50%100%93.55%100, 89–90, 99
   no-wallaby-comment.ts96.77%86.67%100%100%43–44
   regular-expression-comment.ts92.31%88.89%100%94.44%29–30, 47
   require-strict-assert.ts97.30%94.12%100%100%44–45

Copy link

Beta Published - Install Command: npm install @checkdigit/[email protected]

@jpolavar
Copy link
Contributor Author

One other thing to think about is how this combines with the file-path-comment rule. e.g. what happens if we want to disable the no-util-rule? looking at the code it's going to report an error at the first line of the file, but to disable it we'd be breaking the file comment rule? Might want to experiment with this.

@carlansley I tested it , seems problem when we disable no-util-rule. Can we update file-path-rule to not to report file path-error if first line is eslint-disable-next-line @checkdigit/no-util

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add no-util rule
2 participants