@financial-times/eslint-config-reliability-engineering

6.2.7 • Public • Published

eslint-config-reliability-engineering

This is an ESLint configuration which aims to ensure all reliability-engineering applications' source code is consistent in style.

This config extends airbnbs base config along with extra rules provided by eslint-plugin-unicorn, and language/framework specific config

Usage

Install this package together with your application:

npm install --save-dev @financial-times/eslint-config-reliability-engineering

It's recommended to avoid global installs where possible, as eslint in particular can be volatile with dependency locations.

Extend the config using an eslint config file. For example in an .eslintrc.js file:

// .eslintrc.js

const config = require('@financial-times/reliability-engineering')({
    prettier: true, // use prettier, defaults to true
    esModules: true, // use esModules, defaults to false
});

module.exports = Object.assign({}, config, {
    rules: Object.assign({}, config.rules, {
        // Override any settings from the "parent" extended configuration
    }),
});

This root export detects your dependencies from package.json and loads the relevant eslint configs that follow in this list, including prettier.

This is configured using JS to allow for options to be passed in (prettier/esModules) for hard to detect features - esModules can vary per file, and prettier is often installed as a subdependency rather than a direct dependency.

The following configs are also exposed, which allow more granular configuration depending on your choice of tooling, these can be consumed using the standard eslint extends syntax:

// .eslintrc.js

module.exports = {
    extends: ['@financial-times/reliability-engineering/base'],
    rules: {
        // override any rules
    },
};
  • @financial-times/reliability-engineering/base - base (non-react) configuration. Extends the main airbnb rules
  • @financial-times/reliability-engineering/cypress - cypress configuration
  • @financial-times/reliability-engineering/mocha - mocha configuration
  • @financial-times/reliability-engineering/jest - jest configuration. Also reads package.json to determine whether to override file extension rules
  • @financial-times/reliability-engineering/react - react configuration. Extends the main airbnb rules
  • @financial-times/reliability-engineering/prettier - enables formatting with prettier

Dependencies

This package requires certain dependencies as peerDependencies. This is a decision consistent with eslint (see https://github.com/eslint/eslint/issues/2518, https://github.com/eslint/eslint/issues/3458). There is an RFC to address this and allow a package to ship its dependencies: https://github.com/eslint/rfcs/pull/5. This means they should be installed wherever this package is consumed, with matching version ranges:

It's possible to automatically install these by adapting the steps from eslint-config-airbnb-base, e.g. for Linux/OSX:

(
  export PKG=@financial-times/eslint-config-reliability-engineering;
  npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)

Readme

Keywords

none

Package Sidebar

Install

npm i @financial-times/eslint-config-reliability-engineering

Weekly Downloads

0

Version

6.2.7

License

MIT

Unpacked Size

24.1 kB

Total Files

38

Last publish

Collaborators

  • robertboulton
  • seraph2000
  • hamza.samih
  • notlee
  • emmalewis
  • aendra
  • the-ft
  • rowanmanning
  • chee
  • alexwilson