Rel1cx / eslint-react

A series of composable ESLint rules for libraries and frameworks that use React as a UI runtime.
https://eslint-react.xyz
MIT License
156 stars 6 forks source link

Feedback for “filename” #606

Closed bhollis closed 2 weeks ago

bhollis commented 2 weeks ago

From the documentation, it's unclear whether "excepts" accepts a regex or glob. I'd like to turn this rule off for files that match use*.tsx.

Rel1cx commented 2 weeks ago

Hi thanks for the feedback, "excepts" accepts a regex, I will improve the documentation.

Rel1cx commented 2 weeks ago

A better way to turn this rule off for files that match use*.tsx is to utilize the override mechanism of the ESLint config, e.g. in eslint.config.js, we can do something like this:

// ...
export default [
  // ...
  {
    files: ["src/**/*.tsx"],
    rules: {
      "@eslint-react/naming-convention/filename": ["warn", "PascalCase"],
    },
  },
  {
    files: ["src/**/use*.tsx"],
    rules: {
      "@eslint-react/naming-convention/filename": "off"
    },
  },
];

This approach supports applying different naming conventions to different files, which is much more flexible than "excepts".