5.1.0 • Published 9 days ago

@codeyourfuture/eslint-config-standard v5.1.0

Weekly downloads
266
License
ISC
Repository
github
Last release
9 days ago

CYF ESLint Configuration

License Build Status NPM Version

A standard ESLint configuration for all CYF examples/projects.

Versioning

This configuration uses SemVer, interpreted as follows:

  • Patch release (x.y.z -> x.y.z+1): bugfixes and tooling updates mean that code that previously passed linting should continue to pass after the update.

  • Minor release (x.y.z -> x.y+1.0): a change to an existing rule means that code that previously failed linting may now pass, or a new configuration means that code that previously passed linting should continue to pass.

  • Major release (x.y.z -> x+1.0.0): a new rule, or a change to an existing rule, means that code that previously passed linting will not pass any more.

Please bear these definitions in mind when reporting any bugs.

Usage

Install this package along with ESLint itself:

npm install --save-dev eslint @codeyourfuture/eslint-config-standard

Then create an ESLint config file and add this config:

const cyfConfig = require("@codeyourfuture/eslint-config-standard");

module.exports = [cyfConfig];

or using ES module syntax:

import cyfConfig from "@codeyourfuture/eslint-config-standard";

export default [cyfConfig];

Alternatively, for a slightly more permissive set of rules, you can use @codeyourfuture/eslint-config-standard/lax.

.eslintrc

If you have not yet migrated to the newer ESLint "flat config", you can apply these rules to the deprecated config using "extends":

{
  "extends": ["@codeyourfuture/standard"]
}

Principles

  1. Errors only - don't teach trainees to ignore any output, all rules should either be "error" or "off"
  2. Maximise consistency - where there are options (e.g. braces for single-line statements, parentheses around arrow function parameters), be consistent with the non-optional cases
  3. Minimise change set size - keep commits small so trainees can focus on the important changes

Rules

This config starts from js.configs.recommended then adds the following rules:

ConfigurationRuleSettingPrinciples/rationale
standard, laxarrow-parens2, 3
standard, laxbrace-style"1tbs", { "allowSingleLine": false }
standard, laxcomma-dangle"always-multiline"3
standard, laxcurly2
standardindent"tab", { "SwitchCase": 1 }Tabs are more accessible
standardlinebreak-style"unix"
standard, laxno-trailing-spaces
standard, laxno-unused-vars{ "ignoreRestSiblings": true }
standard, laxno-varStick with let and const for more predictable behaviour
standard, laxobject-curly-spacing"always"
standard, laxoperator-linebreak"before"
standard, laxquotes"double", { "avoidEscape": true, "allowTemplateLiterals": false }More likely to need ' inside a string than "
standard, laxsemiTrainees shouldn't have to memorise the ASI rules

Development

You can clone this repo and run npm install to install the development dependencies. Two scripts are provided:

5.1.0

9 days ago

5.0.0

15 days ago

4.0.3

10 months ago

4.0.2

10 months ago

3.0.3

2 years ago

3.0.2

3 years ago

3.0.1

3 years ago

2.1.1

3 years ago

3.0.0

3 years ago

2.1.0

3 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago