Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@open-wc/eslint-config

open-wc57.7kMIT12.0.3

Eslint config following open-wc recommendations

lint, eslint, config

readme

Tools >> Linting and Formatting ||40

We recommend using ESLint to lint your code and prettier to format your code.

This helps catch errors during development, keep a consistent code style, and avoid formatting creating large diffs in pull requests.

Linting config

We recommend @open-wc/eslint-config for a good default configuration for web component projects.

The config includes smart defaults, and installs the following configs and plugins:

Setup

Automated

For an automated setup, use our project generator and choose the linting option.

Manual

To set up our config manually, install the necessary packages:

npm install --save-dev eslint @open-wc/eslint-config prettier eslint-config-prettier

And update your package.json with the commands and config:

{
  "scripts": {
    "lint": "npm run lint:eslint && npm run lint:prettier",
    "format": "npm run format:eslint && npm run format:prettier",
    "lint:eslint": "eslint --ext .js,.html . --ignore-path .gitignore",
    "format:eslint": "eslint --ext .js,.html . --fix --ignore-path .gitignore",
    "lint:prettier": "prettier \"**/*.js\" --check --ignore-path .gitignore",
    "format:prettier": "prettier \"**/*.js\" --write --ignore-path .gitignore"
  },
  "eslintConfig": {
    "extends": ["@open-wc/eslint-config"]
  },
  "prettier": {
    "singleQuote": true,
    "arrowParens": "avoid"
  }
}

IDE Support

Most IDEs have plugins or configuration options available to help with code linting and formatting.

For VSCode we recommend the eslint plugin for highlighting linting errors, and the prettier for formatting on save.

https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint

Lint on commit

To lint changed files on commit, we recommend husky with lint-staged.

Install the necessary packages:

npm install --save-dev husky lint-staged

And update your package.json:

{
  "lint-staged": {
    "*.js": ["eslint --fix", "prettier --write"]
  }
}

Add the lint-staged hook

npx husky add .husky/pre-commit "npx lint-staged"

changelog

Change Log

12.0.3

Patch Changes

  • 43d678fe: add storybook files to devdependencies for no-extraneous-dependencies rule
  • adfb669b: add flat config support for eslint-plugin-import

12.0.2

Patch Changes

12.0.1

Patch Changes

  • 1a2946db: feat: eslint rule

12.0.0

Patch Changes

11.0.0

Major Changes

  • 935c8ffe: Drop support for Node@14

Patch Changes

10.0.0

Patch Changes

9.2.2

Patch Changes

  • f047282c: feat(eslint-config): support import assertions

9.2.1

Patch Changes

  • 285eb1d0: fix(eslint-config): use latest ecmaversion for static class fields su…

9.2.0

Minor Changes

  • e5fa8a8f: feat: update eslint-plugin-lit

9.1.0

Minor Changes

  • 8e2b6b4e: feat(eslint-config): add resolver for package exports/imports for eslint-plugin-import

9.0.0

Major Changes

  • 6525833a: Update aria-query to v5, fix switch role rules
  • 9779c746: Update eslint-plugin-html to 7.1.0
  • dcc4e759: Update eslint-plugin-no-only-tests to 3.1.0

Patch Changes

8.0.2

Patch Changes

8.0.0

Major Changes

  • b321871f: breaking(eslint-config): move eslint to the peerDependencies to let users decide which major version they want to use

7.0.0

Patch Changes

6.0.0

Patch Changes

5.0.0

Patch Changes

5.0.0-next.0

Patch Changes

4.3.0

Minor Changes

  • ad24cd57: added HTML extension

4.2.0

Minor Changes

  • ce208aab: added MJS and TS extensions

4.1.0

Minor Changes

  • 5b774aab: Update eslint-plugin-lit to ^1.3.0

4.0.1

Patch Changes

  • 87ce50c9: Fix peerDependencies in eslint-config

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

4.0.0 (2020-10-24)

Features

  • eslint-config: add lit a11y plugin to openwc eslint config (#1945) (47ac059)

BREAKING CHANGES

  • eslint-config: add lit-a11y plugin to open-wc eslint config

3.0.0 (2020-08-16)

Features

  • eslint-config: upgrade eslint to 7.x (7802511)

BREAKING CHANGES

Additionally, this change also removes the usage of babel-eslint. For most projects, this should work transparently. However, if your code specifically references one of its rules, you can:

  • add @babel/eslint-parser to your devDependencies or
  • remove the references, as some of the rules have been merged into eslint

2.1.0 (2020-08-05)

Features

  • eslint-config: add plugins as peer dependencies (#1740) (3760f77)

2.0.6 (2020-05-05)

Bug Fixes

2.0.5 (2020-04-26)

Note: Version bump only for package @open-wc/eslint-config

2.0.4 (2020-03-06)

Bug Fixes

  • eslint-config: add support for optional chaining (#1399) (79b0683)

2.0.3 (2020-02-09)

Note: Version bump only for package @open-wc/eslint-config

2.0.2 (2019-12-16)

Bug Fixes

  • update linting docu to updates in package.json (e58015c)
  • eslint-config: remove no-property-change-update (f20e924)

2.0.1 (2019-12-08)

Note: Version bump only for package @open-wc/eslint-config

2.0.0 (2019-12-02)

Features

BREAKING CHANGES

  • eslint-config: lit-html templates are now linted as well

1.3.0 (2019-11-03)

Features

  • eslint-config: allow for-of loops in eslint (f6dc2c5)

1.2.0 (2019-10-28)

Features

  • eslint-config: use eslint-plugin-no-only-tests (#914) (41b928d)

1.1.2 (2019-10-23)

Bug Fixes

1.1.1 (2019-08-15)

Bug Fixes

  • eslint-config: set arrow-parens rule (af8f4c7)

1.1.0 (2019-08-14)

Features

  • eslint-config: resolve extended linting configurations (13ee4ba)
  • eslint-config: update dependencies (52909e8)

1.0.0 (2019-07-08)

Bug Fixes

  • use file extensions for imports to support import maps (c711b13)

Features

  • eslint-config: add import extensions linting rule (cd407e7)

BREAKING CHANGES

  • eslint-config: imports now require a file extension every import that is not a "pure" bare import requires a file extension
// before
import '../my-el';
import '@open-wc/testing/index-no-side-effects';
import '@open-wc/testing';
// after
import '../my-el.js';
import '@open-wc/testing/index-no-side-effects.js';
import '@open-wc/testing';

0.4.5 (2019-04-28)

Bug Fixes

  • eslint-config: do not force use of this in life cycle methods (#409) (a407aba)

0.4.4 (2019-04-28)

Bug Fixes

  • eslint-config: loosen up rules for test and stories files (#408) (3fd251e)

0.4.3 (2019-04-14)

Bug Fixes

0.4.2 (2019-03-24)

Bug Fixes

  • adjust generator-open-wc links to create (cc014b1)

0.4.1 (2019-03-08)

Note: Version bump only for package @open-wc/eslint-config

0.4.0 (2019-03-01)

Features

  • eslint-config: add eslint-plugin-wc (be637a5)

0.3.12 (2019-02-24)

Bug Fixes

  • eslint-config: allow usage of devDeps in *.config files (ad52be0)

0.3.11 (2019-02-16)

Bug Fixes

  • update package repository fields with monorepo details (cb1acb7)

0.3.10 (2019-02-02)

Bug Fixes

  • unify npm readme header for all open-wc packages (1bac939)

0.3.9 (2019-01-31)

Bug Fixes

  • eslint-config: allow usage of devDeps in nested test/stories folders (e8663f3)

0.3.8 (2019-01-26)

Bug Fixes

  • align all open-wc readme headers (b589429)

0.3.7 (2019-01-21)

Bug Fixes

0.3.6 (2019-01-20)

Bug Fixes

0.3.5 (2019-01-19)

Bug Fixes

  • restructure menu and improve docu (dd37e22)

0.3.4 (2019-01-16)

Bug Fixes

0.3.3 (2018-12-20)

Bug Fixes

  • linting generators & documentation (5c29f7a)

0.3.2 (2018-12-13)

Bug Fixes

  • apply prettier; add lint-staged (43acfad)

0.3.1 (2018-11-30)

Bug Fixes

  • move documentation to READMEs of packages (b4a0426)

0.3.0 (2018-11-18)

Features

  • use es module chai version; auto-register side-effects (263f4ff)

0.2.1 (2018-10-28)

Bug Fixes

0.2.0 (2018-10-06)

Bug Fixes

  • eslint-config: test/stories folder may import from devDependencies (80bd9e9)
  • add minimal readme (9e52ca2)

Features

  • test: add karma and browserstack (5aff947)

0.1.1 (2018-09-29)

Bug Fixes

  • eslint-config: Use babel-eslint to support dynamic imports (5826475)

0.1.0 (2018-09-17)

Features