0.3.1 • Published 5 years ago

eslint-config-cws v0.3.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

eslint-config-cws

CWS's Javascript ESLint configuration, based on AirBnB's and Prettier's

Install and Usage

1. Installing

Make sure you have Node (>=6) installed

npm install --save-dev eslint-config-cws

2. Using

Create an .eslintrc.json file at the root of your project and add the following configuration:

2.1. Simple setup

For vanilla Javascript code

{
    "extends": "eslint-config-cws"
}

2.2. React setup

For React based apps

{
    "extends": "eslint-config-cws"
}

3. Prettier

Since this config is also based on prettier eslint, it is correct to say that you want to use it in your proejct.

3.1. Prettier installation

Install (prettier)https://prettier.io in your project

npm install --save-dev prettier

3.2. Prettier settings

Create an .prettier.json file at the root of your project and add the following configuration:

{
  "semi": false,
  "singleQuote": true,
  "trailingComma": "all",
  "tabWidth": 2,
  "printWidth": 100,
  "jsxBracketSameLine": false
}

3.3. Prettier npm script

Add to package.json a script to lint your desired files:

{
    "scripts": {
        "prettier": "prettier --config ./.prettierrc.json --write \"src/**/*{.js,.jsx,.css}\""
    }
}

Rules

Please refer to AirBnB's Styleguide or Prettier's for more information about the linter's rules.

Custom rules

This rules overwrite the ones inherited from AirBnB Styleguide

setuprulesetting
allmax-len100 characters {ignoreStrings: true, ignoreTemplateLiterals: true}
allseminever
allquotessingle { allowTemplateLiterals: true }
reactreact/jsx-filename-extensionoff
reactreact/prop-typeswarn
reactjsx-a11y/href-no-hashoff
reactjsx-a11y/label-has-forerror, { allowChildren: true }
reactjsx-a11y/anchor-is-validerror, { specialLink: 'to' }
reactimport/no-extraneous-dependencieserror, { devDependencies: true }
reactimport/no-unresolvederror, { commonjs: true, amd: true }

Maintainers

Willy Camargo

License

MIT