Adds eslint rules to ensure consistent filenames for your javascript files.
Please note: This plugin will only lint the filenames of the .js
-files you are linting with eslint. It will ignore all other files (e.g. non-js files, files not linted with eslint).
Modify your .eslintrc
file to load the plugin and enable the rule.
{
"plugins": [
"filenames"
],
"rules": {
"filenames/filenames": 2
}
}
A rule to enforce a certain file naming convention.
The convention can be configured using a regular expression (the default is camelCase.js
):
"filenames/filenames": [2, "^[a-z_]+$"]
An extra option can be set to check the file name against the default exported value in the module. By default, the exported value is ignored.
The file name must match the regular expression and the exported value name, if any. Example:
"filenames/filenames": [2, "^[a-z_]+$", "match-regex-and-exported"]
// Considered problem only if the file isn't named foo.js
export default function foo() {}
// Always considered problem, since the exported value doesn't match the regular expression
// (conflicting options)
module.exports = class Foo {};
// Considered problem only if the file doesn't match the regular expression
export default { foo: "bar" };
The file name must match the exported value name, if any. Else it should match the regular expression.
"filenames/filenames": [2, "^[a-z_]+$", "match-exported-or-regex"]
// Considered problem only if the file isn't named foo.js
export default foo {}
// Considered problem only if the file isn't named Foo.js
module.exports = class Foo {};
// Considered problem only if the file doesn't match the regular expression
export default { foo: "bar" };
The file name must match the regular expression. Else it should match the exported value name, if any.
"filenames/filenames": [2, "^[a-z_]+$", "match-regex-or-exported"]
// Considered problem only if the file doesn't match the regular expression or isn't named foo.js
export default foo {}
// Considered problem only if the file doesn't match the regular expression or isn't named Foo.js
module.exports = class Foo {};
// Considered problem only if the file doesn't match the regular expression
export default { foo: "bar" };
- Add match-exported flags
- Fix example in README
- Fix: Text via stdin always passes
- Tests: Travis builds also run on node 0.12 and iojs now
- Initial Release