Registry / testing / eslint-plugin-folders

eslint-plugin-folders

JSON →
library1.0.4jsnpmunverified

An ESLint plugin that enforces consistent folder naming conventions for JavaScript/JSX files using regular expressions. Current stable version is 1.0.4. The plugin provides a single rule `match-regex` that can be configured with a regex pattern and a root directory. It only lints folders containing `.js` or `.jsx` files processed by ESLint. Alternatives like `eslint-plugin-import` or `eslint-plugin-filenames` focus on filenames, not folder names. The plugin requires ESLint >=1.0.0 as a peer dependency.

npm install eslint-plugin-folders
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-FOLD
E
eslint-plugin-folders
testingjavascriptv1.0.4
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
✓ module.exports = { plugins: ['folders'], rules: { 'folders/match-regex': [2, '^[a-z_]+$', '/root/'] } };
✗ import folders from 'eslint-plugin-folders'
This is an ESLint plugin, not a standalone module. It's configured via .eslintrc rather than imported in code.
match-regex
✓ "folders/match-regex": [2, "^[a-z_]+$", "/root/"]
✗ "folders/match-regex": [2, "/^[a-z_]+$/", "/root/"]
The regex is provided as a string without slashes. The second parameter is the root path.
RULES
✓ const rules = require('eslint-plugin-folders').rules; console.log(Object.keys(rules));
✗ const { matchRegex } = require('eslint-plugin-folders');
The plugin exposes a rules object. Individual rules are accessed via string keys like 'match-regex'.

Shows how to configure the match-regex rule in .eslintrc.json to enforce snake_case folder names.

// .eslintrc.json { "plugins": ["folders"], "rules": { "folders/match-regex": [2, "^[a-z_]+$", "."] } } // This config enforces snake_case folder names in all folders below the root. // To test, create a folder with a wrong name (e.g., 'MyFolder') containing a JS file. // Run ESLint: npx eslint . // You'll see an error like: // error Folder 'MyFolder' doesn't match the pattern ^[a-z_]+$ folders/match-regex
Debug
Known issues
gotchaThe plugin only lints folders of .js and .jsx files. Folders without JS/JSX files are ignored.
fix
Ensure each folder you want to lint contains at least one .js or .jsx file that ESLint processes.
affects: >=0.0.0
gotchaThe regex pattern is provided as a string without delimiters. E.g., '^[a-z_]+$' not '/^[a-z_]+$/'.
fix
Use plain regex string without surrounding slashes.
affects: >=0.0.0
breakingESLint >=1.0.0 required. Older versions may not load the plugin correctly.
fix
Upgrade ESLint to version 1.0.0 or later.
affects: <1.0.0
Errors
Common errors & fixes
Error: .eslintrc: Configuration for rule "folders/match-regex" is invalid
The rule configuration format is wrong; typically the regex is not a string.
fix
Use an array: [severity, patternString, rootPath]. E.g., [2, "^[a-z]+$", "."].
Error: Cannot find module 'eslint-plugin-folders'
Plugin not installed as a dev dependency.
fix
Run: npm install eslint-plugin-folders --save-dev
Parsing error: The keyword 'const' is reserved
ESLint is not configured for ES6 syntax.
fix
Set parserOptions: { ecmaVersion: 6 } in .eslintrc or use a parser like babel-eslint.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required to load and run the plugin
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-folders — npm install eslint-plugin-folders · libregistry