36.0.0 • Published 9 months ago

@sky-uk/eslint-config-sky v36.0.0

Weekly downloads
16,180
License
BSD-3-Clause
Repository
github
Last release
9 months ago

eslint-config-sky

ESLint config for Sky JavaScript projects. Aside from linting rules, this also enforces the use of ES6 either via Node or transpilation (probably via Babel).

Purpose

  • Provide strict eslint configuration
  • Codification of consistency and best practices
  • Increased stylistic consistency in JavaScript projects at Sky
  • Less time spent debating stylistic issues in code reviews
  • Perform error checking prior to execution

Prettier

  • This eslint config now relies on Prettier for many stylistic rules. See https://prettier.io/ for more information. You do not have to run Prettier separately as we run it through eslint-plugin-prettier.

Contributing

For information on the process of contributing to this library, please read the contributing guide.

Getting started

1. Install:

To install eslint-config-sky and all required peerDependencies at the correct versions:

npm info "@sky-uk/eslint-config-sky" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-exact --save-dev "@sky-uk/eslint-config-sky"

You may not need all the peer dependencies - for example you don't need eslint-plugin-react if you are not using React - so you may need to then remove some of the peer dependencies that have been automatically installed from your package.json.

When installing or updating the version of eslint-config-sky you should also make sure the versions of the other libraries are at a minimum the versions specific in the peer dependencies of this package.

You should always point to a specific version of eslint-config-sky as referencing the latest will break your CI when new rules are introduced.

2. Create or extend your .eslintrc:

{
  "extends": ["@sky-uk/eslint-config-sky"],
  "env": {
    "browser": true/false,
    "node": true/false
  }
}

See here for more environment options.

3. NPM scripts

It is recommended to create npm scripts to run your linting through. To do so, add the following to the scripts object in your package.json.

{
  "scripts": {
    "lint": "eslint .",
    "format": "npm run lint -- --fix"
  }
}

4. Automatically fix problems

You can use npm run format to automatically fix most errors.

If, after running format you still find you have a lot of linting issues you can set those rules to warn for the time being until you have time to work through them. You can do this by adding a rules section to your .eslintrc.

{
  "rules": {
    "import/no-named-as-default": "warn"
  }
}

5. Check linting in your CI

You can add the npm run lint command to your CI to make sure that no linting problems are introduced.

Extensions

If you use a specific library, then you can install the extension for it in addition to the base Sky config.

If you do not use these, you will get peer dependency warnings on npm install but they can be ignored.

react

Install:

npm install --save-dev eslint-plugin-react

Extend your .eslintrc:

{
  "extends": [
      ...
      "@sky-uk/eslint-config-sky/react"
  ]
}

mocha

Install:

npm install --save-dev eslint-plugin-mocha

Extend your .eslintrc:

{
  "extends": [
      ...
      "@sky-uk/eslint-config-sky/mocha"
  ]
}

Examples:

36.0.0

9 months ago

35.0.0

12 months ago

35.0.1

11 months ago

34.0.0

2 years ago

33.3.0

2 years ago

33.2.0

3 years ago

33.1.3

3 years ago

33.1.2

3 years ago

33.1.1

3 years ago

33.1.0

3 years ago

33.0.0-alpha.0

4 years ago

33.0.0

4 years ago

32.1.0

4 years ago

32.0.1

4 years ago

32.0.0

4 years ago

31.0.0

4 years ago

30.0.0

4 years ago

29.0.1

4 years ago

28.0.1

4 years ago

27.1.0

4 years ago

27.0.0

5 years ago

26.0.0

5 years ago

25.4.0

6 years ago

25.3.0

6 years ago

25.2.0

6 years ago

25.1.0

6 years ago

25.0.0

6 years ago

24.0.2-0

6 years ago

24.0.1

6 years ago

23.0.0

6 years ago

22.1.0

6 years ago

22.0.0

6 years ago

21.0.0

6 years ago

20.1.0

6 years ago

20.0.0

6 years ago

19.1.0

7 years ago

19.0.0

7 years ago

18.1.0

7 years ago

18.0.0

7 years ago

17.1.0

7 years ago

17.0.0

7 years ago

16.1.0

7 years ago