Skip to content

Latest commit

 

History

History
 
 

eslint-config

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Linting ESLint

Use ESLint to lint your es6 code.

Setup

npm init @open-wc
# Upgrade > Linting

::: tip 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
  • Apply linting for best practices
  • 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:eslint to check if any file is not correctly formatted
  • npm run format:eslint to auto format your files
<script> export default { mounted() { const editLink = document.querySelector('.edit-link a'); if (editLink) { const url = editLink.href; editLink.href = url.substr(0, url.indexOf('/master/')) + '/master/packages/eslint-config/README.md'; } } } </script>