Skip to content
Shareable ESLint config following Torchbox’s code style
JavaScript Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.githooks
.github
src
.editorconfig
.eslintrc.js
.gitignore
.nvmrc
.prettierignore
.prettierrc.toml
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE
README.md
config.js
package-lock.json
package.json

README.md

eslint-config-torchbox ESLint

eslint-config-torchbox on npm Build Status

Shareable ESLint config following Torchbox’s code style.

Usage

Install the config along with its peer dependencies:

npx install-peerdeps --dev eslint-config-torchbox@latest

Then configure ESLint to use this config. As a .eslintrc.js in the root of your project:

module.exports = {
  // See https://github.com/torchbox/eslint-config-torchbox for rules.
  extends: 'torchbox',
};

Tips

  • Use ESLint’s --report-unused-disable-directives flag to ensure you do not use more eslint-disable comments than needed.
  • This config is Prettier-compatible, but it is still usable by projects which do not wish to use Prettier.
  • We recommend using a .eslintignore so ESLint can be targeted at all files, with a blacklist of files to ignore.

Here’s a package.json run script and an ignore file to get you started:

"lint:js": "eslint --report-unused-disable-directives .",

.eslintignore (adapt to your project):

.git
node_modules
coverage
static_compiled
venv

Note the point of the ignore file isn’t just to determine which JS files we don’t want to be linted, but also speed up linting by excluding large folders.

React

This config is meant first and foremost for React projects, where it will detect which rules to apply based on the version of React used on the project. The config can also be used on non-React projects – just make sure to disable the version check by adding: the following in your config:

module.exports = {
  // [...]
  settings: {
    // Manually set the version to disable automated detection of the "react" dependency.
    react: { version: 'latest' },
  },
};

Experimental syntax

By default, this config uses ESLint’s built-in parser, which doesn’t support experimental ECMAScript features. If your code uses experimental syntax transpiled with Babel, make sure to set the ESLint parser to babel-eslint:

module.exports = {
  // See https://github.com/torchbox/eslint-config-torchbox for rules.
  extends: 'torchbox',
  // Support non-standard, experimental JS features that Babel knows how to process.
  parser: 'babel-eslint',
};

What’s included

See config.js for the config definition, and semver.test.js.snap for the whole set of rules and settings.

Extends

Custom rules

Inherited rules

Contributing

See the contribution guidelines for guidance and setup instructions.

You can’t perform that action at this time.