eslint-plugin-check-file
raw JSON → 3.3.1 verified Sat Apr 25 auth: no javascript
ESLint plugin for enforcing consistent naming conventions for files and folders. Current stable version is 3.3.1, requiring Node >=18 and ESLint >=9 with flat config. Provides five rules: no-index, filename-blocklist, folder-match-with-fex, filename-naming-convention (supports built-in cases like PASCAL_CASE, CAMEL_CASE, NEXT_JS_PAGE_ROUTER_FILENAME_CASE), and folder-naming-convention. Unlike generic naming tools, it uses glob patterns to target specific file paths and supports linting non-JS/TS files via a dedicated processor. Ships TypeScript definitions.
Common errors
error Error: Cannot find module 'eslint-plugin-check-file' ↓
cause Missing dependency or wrong import path when using ESM in non-module context.
fix
Run 'npm install eslint-plugin-check-file --save-dev' and ensure the import uses ESM syntax or a bundler.
error TypeError: eslint.PLUGIN_VERSION is not a function ↓
cause Using v3 with ESLint <9 or legacy .eslintrc config.
fix
Upgrade ESLint to >=9 and switch to flat config (eslint.config.js).
error Parsing error: The keyword 'import' is reserved ↓
cause Attempting to use ESM import in a CommonJS file without .mjs extension or type:'module' in package.json.
fix
Rename eslint.config.js to eslint.config.mjs or add 'type': 'module' to package.json.
error Error: No configuration found for file '...' ↓
cause File does not match any 'files' pattern in eslint config.
fix
Add a 'files' pattern that includes the file's path (e.g., ['**/*.js']).
Warnings
breaking v3 migrated to ESM-only and flat config; Node <18 and ESLint <9 not supported. ↓
fix Upgrade Node to >=18, ESLint to >=9, and use flat config syntax (eslint.config.js).
breaking v3 requires ESLint flat config; legacy .eslintrc.* files are ignored. ↓
fix Convert .eslintrc.* to eslint.config.js using plugins array with object syntax.
deprecated v3 removes support for CommonJS; require() will throw. ↓
fix Use ESM imports (import) or dynamic import() in CJS contexts.
gotcha The 'processor' field is required for non-JS/TS files like .yaml, .webp. Without it, those files are skipped. ↓
fix Add 'processor: "check-file/eslint-processor-check-file"' to the file config block.
gotcha Glob patterns in rules must match file paths relative to the project root; incorrect patterns cause rules to silently not apply. ↓
fix Test patterns using ESLint's --debug flag or run with a single file to verify matching.
Install
npm install eslint-plugin-check-file yarn add eslint-plugin-check-file pnpm add eslint-plugin-check-file Imports
- checkFile wrong
const checkFile = require('eslint-plugin-check-file')correctimport checkFile from 'eslint-plugin-check-file' - rules wrong
import { rules } from 'eslint-plugin-check-file'correctimport { rules } from 'eslint-plugin-check-file' - FlatConfig wrong
module.exports = { plugins: ['check-file'] }correctimport checkFile from 'eslint-plugin-check-file'; export default [ { plugins: { 'check-file': checkFile } } ]
Quickstart
// eslint.config.js
import checkFile from 'eslint-plugin-check-file';
export default [
{
files: ['src/**/*.{js,ts,jsx,tsx}'],
plugins: {
'check-file': checkFile,
},
rules: {
'check-file/filename-naming-convention': [
'error',
{
'**/*.{jsx,tsx}': 'PASCAL_CASE',
'**/*.{js,ts}': 'CAMEL_CASE',
},
],
'check-file/folder-naming-convention': [
'error',
{
'src/components/*': 'PASCAL_CASE',
},
],
'check-file/no-index': 'error',
},
},
];
// Run: npx eslint src/