eslint-plugin-filenames

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

An ESLint plugin that adds rules to enforce consistent file naming conventions in JavaScript projects. The latest stable version is 1.3.2. It provides three rules: match-regex for custom regex patterns, match-exported to match filenames to default exports, and no-index to disallow index.js files. The plugin is no longer actively maintained (last release 2018). It requires ESLint >=1.0.0 as a peer dependency. Key differentiator: it specifically lints filenames within ESLint's scope, not the entire filesystem.

error Error: Failed to load plugin 'filenames' declared in '.eslintrc': Cannot find module 'eslint-plugin-filenames'
cause Plugin not installed as npm package.
fix
Run: npm install eslint-plugin-filenames --save-dev
error Configuration for rule "filenames/match-regex" is invalid: Expected an array but got number
cause Using just severity number without array for rule that expects options.
fix
Change from "filenames/match-regex": 2 to "filenames/match-regex": [2, "^[a-z_]+$", true]
error ESLint: Rule 'filenames/match-exported' requires a string or array of strings for transforms, got undefined
cause Using match-exported with no arguments (just severity), but expecting second argument.
fix
Provide a transform (e.g., 'kebab') or null: "filenames/match-exported": [2, null]
deprecated This project is no longer actively maintained. Last release in 2018. May not work with modern ESLint versions (>=7).
fix Consider alternatives like eslint-plugin-unicorn (unicorn/filename-case) or eslint-plugin-perfectionist.
gotcha Only lints filenames of .js and .jsx files that are already being linted by ESLint. Does not check other files like .ts, .tsx, .json, etc.
fix For TypeScript files, use eslint-plugin-unicorn/filename-case or write custom rule.
gotcha The match-regex rule's second argument (ignoreExporting) defaults to false if only one argument provided. Many users omit it assuming default is 'camelCase.js' without export ignoring.
fix Always provide both arguments to match-regex: [severity, regex, ignoreExporting]. Example: [2, '^[a-z_]+$', true].
gotcha match-exported does not respect exported function calls (e.g., export default someFunction()). Only respects function declarations, classes, and variable assignments.
fix For complex exports, consider using a different plugin or adjust naming convention manually.
npm install eslint-plugin-filenames-ts
yarn add eslint-plugin-filenames-ts
pnpm add eslint-plugin-filenames-ts

Shows basic ESLint configuration to enable all three plugin rules with example transform.

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

// Example file: my-file.js
export default function myFile() {}
// This file passes match-regex and match-exported (kebab transform matches 'my-file').