JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 486563
  • Score
    100M100P100Q184854F
  • License MIT

Eslint rule for consistent filenames.

Package Exports

  • eslint-plugin-filenames

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-filenames) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

eslint-plugin-filenames

NPM Version Build Status Coverage Status Dependencies

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).

Enabling the plugin

Modify your .eslintrc file to load the plugin and enable the rule.

{
  "plugins": [
    "filenames"
  ],
  "rules": {
    "filenames/filenames": 2
  }
}

Rules

Consistent Filenames (filenames)

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.

"match-regex-and-exported" or "match-exported-and-regex"

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 doen't match the regular expression
export default { foo: "bar" };

"match-exported-or-regex"

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" };

"match-regex-or-exported"

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" };

Changelog

0.2.0

  • Add match-exported flags

0.1.2

  • Fix example in README

0.1.1

  • Fix: Text via stdin always passes
  • Tests: Travis builds also run on node 0.12 and iojs now

0.1.0

  • Initial Release