{"id":19755,"library":"eslint-plugin-filenames","title":"eslint-plugin-filenames","description":"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.","status":"maintenance","version":"1.3.2","language":"javascript","source_language":"en","source_url":"git://github.com/selaux/eslint-plugin-filenames","tags":["javascript","eslint","eslintplugin","eslint-plugin","file","filename","path"],"install":[{"cmd":"npm install eslint-plugin-filenames","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-filenames","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-filenames","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; requires eslint >=1.0.0","package":"eslint","optional":false}],"imports":[{"note":"This is an ESLint plugin, not an importable module in code. Register it in your ESLint config under 'plugins'.","wrong":"require('eslint-plugin-filenames') without registering","symbol":"plugin","correct":"plugins: ['filenames'] in .eslintrc"},{"note":"The rule accepts an array with regex pattern and optional boolean for ignoring exported files.","wrong":"rules: { 'filenames/match-regex': 'error' } (missing array)","symbol":"match-regex","correct":"rules: { 'filenames/match-regex': [2, '^[a-z_]+$'] }"},{"note":"Transform parameter can be a string, an array of strings/null, or omitted. Use null for no transform.","wrong":"rules: { 'filenames/match-exported': [2, 'camel'] } (transform names are lowercase strings, e.g. 'camel', 'kebab')","symbol":"match-exported","correct":"rules: { 'filenames/match-exported': 2 }"},{"note":"Simple rule; no options. Just set severity.","wrong":"rules: { 'filenames/no-index': 'error' } (should be numeric severity)","symbol":"no-index","correct":"rules: { 'filenames/no-index': 2 }"},{"note":"This package is CommonJS only; ESM import may fail in Node.js without bundler.","wrong":"import plugin from 'eslint-plugin-filenames' (ESM not supported)","symbol":"all rules","correct":"const plugin = require('eslint-plugin-filenames'); plugin.rules"}],"quickstart":{"code":"// 1. Install the plugin and ESLint\n// npm install eslint eslint-plugin-filenames --save-dev\n\n// 2. Create .eslintrc.json:\n{\n  \"plugins\": [\"filenames\"],\n  \"rules\": {\n    \"filenames/match-regex\": [2, \"^[a-z_]+$\"],\n    \"filenames/match-exported\": [2, null, \"\\\\.react$\"],\n    \"filenames/no-index\": 2\n  }\n}\n\n// 3. Create a file test-foo.js (not matching regex) and run:\n// npx eslint test-foo.js\n// Expected output: error: Filename does not match the naming convention (filenames/match-regex)","lang":"javascript","description":"Shows installation, ESLint configuration with all three rules, and a test that triggers match-regex."},"warnings":[{"fix":"Ensure all files you want to lint are included in ESLint's --ext or config.","message":"Plugin only lints files that ESLint processes; non-JS/JSX files are ignored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider migrating to eslint-plugin-simple-filenames or eslint-plugin-unicorn's filename rule.","message":"Package is no longer actively maintained; last release in 2019.","severity":"deprecated","affected_versions":">=1.3.0"},{"fix":"Use only default export patterns like function, class, or variable declarations.","message":"match-exported rule does not respect exported function calls; it only matches names of default exports.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Example: [2, [null, 'kebab', 'snake']] instead of [2, ['kebab', 'snake']].","message":"match-exported with multiple transforms: use null for no transform (not omitted).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install eslint-plugin-filenames --save-dev and ensure it's in the same directory as your .eslintrc.","cause":"Plugin is not installed or not in node_modules.","error":"ESLint couldn't find the plugin \"eslint-plugin-filenames\""},{"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_]+$\"].","cause":"Severity must be a number or string like 'error', not an array if not using options.","error":"Configuration for rule \"filenames/match-regex\" is invalid: Value [2, \"^[a-z_]+$\"] is not a valid severity."},{"fix":"Add 'filenames' to the plugins array in your ESLint config.","cause":"Plugin not properly registered; eslint cannot access rules.","error":"Cannot read property 'match' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}