mirror of
https://github.com/jlengrand/open-wc.git
synced 2026-03-10 08:31:19 +00:00
2.3 KiB
2.3 KiB
Linting ESLint
Part of Open Web Component Recommendation open-wc Recommendations open-wc
Open Web Components provides a set of defaults, recommendations and tools to help facilitate your Web Component. Our recommendations include: developing, linting, testing, tooling, demoing, publishing and automating.
Use ESLint to lint your es6 code.
Setup
npx -p yo -p generator-open-wc -c 'yo open-wc:lint-eslint'
::: tip Info This is part of the default open-wc recommendation :::
Manual
yarn add --dev @open-wc/eslint-config- Copy .eslintignore to
.eslintignore - Copy .eslintrc.js to
.eslintrc.js - Add these scripts to your package.json
"scripts": { "lint:eslint": "eslint --ext .js,.html .", "format:eslint": "eslint --ext .js,.html . --fix" },
What you get
This will install @open-wc/eslint-config, a config based on airbnb but allows for some specialities needed for Web Components.
- Apply linting to js and html files
- Allow dynamic module imports
- Allow imports in test/demos from devDependencies
- Allow underscore dangle
- Do not prefer default exports
- Do not prefer no file extension
Usage
Run:
npm run lint:eslintto check if any file is not correctly formattednpm run format:eslintto auto format your files