A set of eslint shareable configurations for javascript code style, which follows ADoyle's code style.
The configurations for browser and server development. It supports ES6, and React/JSX.
- Code style with my best practice
- Configurations for different environments
- Optional eslint-plugin configurations
- Semver-checking with eslint-plugin configuration
# ATTENTION: Use `npm install -E` to install exact version.
npm install -DE eslint-config-adoyle-style
npm install -D eslint@7
# Only for browser
npm install -D eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react
# If your project use babel
npm install -D eslint-plugin-babel babel-eslint
# If your project use jest
npm install -D eslint-plugin-jest
Edit your .eslintrc
file. Apply different code styles as below:
It's default for ES6 syntax and ES6 global variables:
root: true
extends: adoyle-style/node
overrides:
# This override is optional. You should install eslint-plugin-jest by yourself.
- files:
- '**/*.test.js'
- '**/__mocks__/*.js'
extends: adoyle-style/node/testing
"adoyle-style/node/testing" includes much appropriate plugins which installed by yourself.
It's default for ES5 syntax:
root: true
extends: adoyle-style/browser
If you use ES6 syntax:
root: true
extends:
- adoyle-style/browser
- adoyle-style/browser/es6
Additional React/JSX support:
root: true
extends:
- adoyle-style/browser
- adoyle-style/browser/es6
- adoyle-style/plugin/import
- adoyle-style/plugin/jsx-a11y
- adoyle-style/plugin/react
Additional Jest support:
root: true
extends:
- adoyle-style/node
- adoyle-style/plugin/jest
Additional Babel support:
root: true
extends:
- adoyle-style/node
- adoyle-style/plugin/babel
Additional import support:
root: true
extends:
- adoyle-style/node
- adoyle-style/plugin/import
Attention!
You should install each devDependency by yourself when using the adoyle-style/plugin/*
. And each package's version should under the optionalDependencies
. Such as eslint-plugin-jsx-a11y
, eslint-plugin-import
, eslint-plugin-react
.
@TODO
# install node modules
npm i
# update eslint related deps to latest
./tools/update_eslint_deps
# To show all differences between latest and current rules.
./tools/what_news
Then edit rules by yourself.
# To query rule description
./tools/find_rule $rule_name
# For example
./tools/find_rule default-param-last
#{
# "type": "suggestion",
# "docs": {
# "description": "enforce default parameters to be last",
# "category": "Best Practices",
# "recommended": false,
# "url": "https://eslint.org/docs/rules/default-param-last"
# },
# "messages": {
# "shouldBeLast": "Default parameters should be last."
# }
#}
./tools/find_rule import/imports-first
# {
# "type": "suggestion",
# "docs": {
# "url": "https://github.com/benmosher/eslint-plugin-import/blob/7b25c1cb95ee18acc1531002fd343e1e6031f9ed/docs/rules/imports-first.md"
# },
# "fixable": "code",
# "deprecated": true
# }
The versioning follows the rules of SemVer 2.0.0.
For more information on SemVer, please visit http://semver.org/.
Copyright 2020-2021 ADoyle ([email protected]). The project is licensed under the BSD 3-clause License.
See the LICENSE file for the specific language governing permissions and limitations under the License.
See the NOTICE file distributed with this work for additional information regarding copyright ownership.