eslint-plugin-filenames

raw JSON →
1.3.2 verified Sat Apr 25 auth: no javascript maintenance

An ESLint plugin that enforces consistent filenames for JavaScript files. Current stable version is 1.3.2 (last updated 2019). It provides three rules: `match-regex` for custom regex patterns, `match-exported` to align filename with the default export, and `no-index` to disallow `index.js` files. The plugin only lints `.js` and `.jsx` files that ESLint processes. Unlike alternatives like `eslint-plugin-filenames-simple` or `eslint-plugin-unicorn`'s filename rule, this one is lightweight and focused, but note it is not actively maintained.

error ESLint couldn't find the plugin "eslint-plugin-filenames"
cause Plugin is not installed or not in node_modules.
fix
Run npm install eslint-plugin-filenames --save-dev and ensure it's in the same directory as your .eslintrc.
error Configuration for rule "filenames/match-regex" is invalid: Value [2, "^[a-z_]+$"] is not a valid severity.
cause Severity must be a number or string like 'error', not an array if not using options.
fix
Use a number for severity if no options: "filenames/match-regex": 2. If using options, keep array format but ensure first element is severity: [2, "^[a-z_]+$"].
error Cannot read property 'match' of undefined
cause Plugin not properly registered; eslint cannot access rules.
fix
Add 'filenames' to the plugins array in your ESLint config.
gotcha Plugin only lints files that ESLint processes; non-JS/JSX files are ignored.
fix Ensure all files you want to lint are included in ESLint's --ext or config.
deprecated Package is no longer actively maintained; last release in 2019.
fix Consider migrating to eslint-plugin-simple-filenames or eslint-plugin-unicorn's filename rule.
gotcha match-exported rule does not respect exported function calls; it only matches names of default exports.
fix Use only default export patterns like function, class, or variable declarations.
gotcha match-exported with multiple transforms: use null for no transform (not omitted).
fix Example: [2, [null, 'kebab', 'snake']] instead of [2, ['kebab', 'snake']].
npm install eslint-plugin-filenames
yarn add eslint-plugin-filenames
pnpm add eslint-plugin-filenames

Shows installation, ESLint configuration with all three rules, and a test that triggers match-regex.

// 1. Install the plugin and ESLint
// npm install eslint eslint-plugin-filenames --save-dev

// 2. Create .eslintrc.json:
{
  "plugins": ["filenames"],
  "rules": {
    "filenames/match-regex": [2, "^[a-z_]+$"],
    "filenames/match-exported": [2, null, "\\.react$"],
    "filenames/no-index": 2
  }
}

// 3. Create a file test-foo.js (not matching regex) and run:
// npx eslint test-foo.js
// Expected output: error: Filename does not match the naming convention (filenames/match-regex)