Open Hotell opened 5 years ago
So I dig into the source a bit, and the problem is not within lookahead. the issue is that the lint rule is matching only against filename, whilst ignoring the extension.
👉 https://github.com/selaux/eslint-plugin-filenames/blob/master/lib/rules/match-regex.js#L29
when changed to
matchesRegex = conventionRegexp.test(`${parsed.name}${parsed.ext}`)
everything is validate correctly.
Now question is how to proceed with this. I see two options:
WDYT? I'll submit PR after we get to an agreement.
Cheers
I created my own plugin for the same purpose, it validates against the full name instead.
As an alternative, you can use eslint-plugin-project-structure
ESLint plugin with rules to help you achieve a scalable, consistent, and well-structured project.
Create your own framework! Define your folder structure, advanced naming conventions, file composition, and create independent modules.
Take your project to the next level and save time by automating the review of key principles of a healthy project!
Enforce rules on folder structure to keep your project consistent, orderly and well thought out.
A key principle of a healthy project is to prevent the creation of a massive dependency tree, where removing or editing one feature triggers a chain reaction that impacts the entire project.
Create independent modules to keep your project scalable and easy to maintain. Get rid of dependencies between modules and create truly independent functionalities.
Enforce advanced naming rules and prohibit the use of given selectors in a given file.
Have full control over what your file can contain and the naming conventions it must follow.
I wanna trigger lint error when barrel ( index ) file has
.tsx
extension.Also this rule should check that files use kebab case only.
my regex rule:
index.tsx
-> NO ERORR (WRONG ❌ )foo-bar.tsx
-> NO ERROR (✅)FooBar.tsx
-> ERROR (kebab case only) (✅)regex is valid: https://regexr.com/