Last active
March 10, 2016 10:04
-
-
Save ahmed1490/5f17cd9f5bc3df52c797 to your computer and use it in GitHub Desktop.
ES List description
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| env: { | |
| es6: true | |
| }, | |
| parserOptions: { | |
| sourceType: 'module', | |
| ecmaVersion: 6, | |
| ecmaFeatures: { | |
| modules: true, | |
| experimentalObjectRestSpread: true | |
| } | |
| }, | |
| globals: { | |
| jQuery: true, | |
| __: false | |
| } | |
| "rules": { | |
| "brace-style": [2, "1tbs"], | |
| "comma-style": [2, "last"], | |
| "indent": [2, 4, { "SwitchCase": 1 }], | |
| "no-constant-condition": 2, | |
| "semi": [2, "always"], | |
| "space-after-keywords": [2, "always"], | |
| "space-before-blocks": [2, "always"], | |
| "strict": [2, "never"], | |
| "quotes": [2, "single"], | |
| "react/self-closing-comp": 1, | |
| "react/no-did-mount-set-state": 1, | |
| "react/no-did-update-set-state": 1, | |
| "react/jsx-uses-react": 1, | |
| "react/jsx-uses-vars": 1, | |
| "react/react-in-jsx-scope": 1 | |
| }, | |
| "plugins": [ | |
| "react" | |
| ], | |
| "extends": "plugin:react/recommended", | |
| "extends": "airbnb" | |
| "extends": "meteor" | |
| } |
Author
Author
Lets start...
- get started with
npm install eslint --save-dev&&eslint --init
4 ways to define linting
- package.json
{
"name": "mypackage",
"version": "0.0.1",
"eslintConfig": {
"env": {
"browser": true,
"node": true
}
}
}
- .eslintrc
{
...
}
- command line
--- globals: var1: true var2: false - on the top of each file with comments
/*eslint-env node, mocha */
eslint 2.x vs 1.x
You can nest .eslintrc files
check sample fragment
- if you use webpack, add
eslint-loaderin yourwepack.dev.jsas a preloader (preloader so that your colleage doesnt makes mistake to putbabel-loaderbefore theeslint-loader)
others bla bla
Read the manual
http://eslint.org/docs/user-guide/configuring
Author
https://github.com/stylelint/stylelint
facebook flow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
4 ways to use external libs
Plugins
eslint-plugin-xxxLets look at
#### plugin definition - **How does the plugin define it** and exposes..
Environtments
eg: eslint-plugin-jquery exposes env called jquery with global var $ which cannot be overwritten.
environments: { jquery: { globals: { $: false } } }eg: another example is
eslint-plugin-reactwhich has react specific bindings (usesbabel-eslintfor some features internally) ...Configs
#### plugin usage in .eslintrc - first declare you are going to use the plugin in your .eslintrc
To use the rules in your linting there are two ways
rules:{}setb. extend a set of predefined ruleset called config
this config can be simple .eslintrc file from a lib and extended in your .eslintrc as
or extend a config exported by a library
eg: "recommended" config exported from eslint-plugin-react looks like
and you can be use the set of configs inside your eslintrc using "extend"
lib code : https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/index.js
find included rules here : http://eslint.org/docs/user-guide/migrating-to-2.0.0.html#new-rules-in-eslintrecommended
Lastly, which we already cover..
using lib/individual-rule(s)