mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 16:37:54 -05:00
Compare commits
31 Commits
eslint-con
...
es5-deprec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4d8543f12 | ||
|
|
a6da4bb5b2 | ||
|
|
6857f7af97 | ||
|
|
cb36ed90c3 | ||
|
|
75c961a43f | ||
|
|
a533e2dd35 | ||
|
|
4425d3c76b | ||
|
|
49dfcc42de | ||
|
|
b2ea03ef2c | ||
|
|
4dbb2af7da | ||
|
|
1917968acb | ||
|
|
0165c13845 | ||
|
|
4c8f78921f | ||
|
|
eea5f0f5f5 | ||
|
|
1fb300c6c7 | ||
|
|
616233c8b2 | ||
|
|
bbfb9600dc | ||
|
|
da3eb59b39 | ||
|
|
892128366a | ||
|
|
9d598c3563 | ||
|
|
4921e03a7b | ||
|
|
df8627d72f | ||
|
|
3594ee94ac | ||
|
|
623dc44bb9 | ||
|
|
ca9c322790 | ||
|
|
762177eb3b | ||
|
|
2504e0f85c | ||
|
|
385fc9effe | ||
|
|
723e12a87d | ||
|
|
97da7b65c6 | ||
|
|
abcc0c681e |
3
packages/eslint-config-airbnb-base/.babelrc
Normal file
3
packages/eslint-config-airbnb-base/.babelrc
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"presets": ["airbnb"]
|
||||
}
|
||||
@@ -1,3 +1,18 @@
|
||||
5.0.1 / 2016-07-29
|
||||
==================
|
||||
- [patch] `no-unused-expressions`: flesh out options
|
||||
- [deps] update `eslint` to `v3.2`, `eslint-plugin-import` to `v1.12`
|
||||
- [tests] improve prepublish script
|
||||
|
||||
5.0.0 / 2016-07-24
|
||||
==================
|
||||
- [breaking] enable `import/newline-after-import`
|
||||
- [breaking] enable overlooked rules: `linebreak-style`, `new-parens`, `no-continue`, `no-lonely-if`, `operator-assignment`, `space-unary-ops`, `dot-location`, `no-extra-boolean-cast`, `no-this-before-super`, `require-yield`, `no-path-concat`, `no-label-var`, `no-void`, `constructor-super`, `prefer-spread`, `no-new-require`, `no-undef-init`, `no-unexpected-multiline`
|
||||
- [deps] update `eslint`, `eslint-find-rules`, `eslint-plugin-import`, `babel-tape-runner`; add `babel-preset-airbnb`
|
||||
- [patch] flesh out defaults: `jsx-quotes`
|
||||
- [docs] update the peer dep install command to dynamically look up the right version numbers when installing peer deps
|
||||
- [tests] fix prepublish scripts
|
||||
|
||||
4.0.2 / 2016-07-14
|
||||
==================
|
||||
- [fix] repair accidental comma-dangle change
|
||||
|
||||
@@ -12,15 +12,41 @@ We export two ESLint configurations for your usage.
|
||||
|
||||
Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`.
|
||||
|
||||
1. `npm install --save-dev eslint-config-airbnb-base eslint-plugin-import eslint`
|
||||
2. add `"extends": "airbnb-base"` to your .eslintrc
|
||||
1. Ensure packages are installed with correct version numbers by running:
|
||||
```sh
|
||||
(
|
||||
export PKG=eslint-config-airbnb-base;
|
||||
npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG"
|
||||
)
|
||||
```
|
||||
|
||||
Which produces and runs a command like:
|
||||
|
||||
```sh
|
||||
npm install --save-dev eslint-config-airbnb-base eslint@^3.0.1 eslint-plugin-import@^1.10.3
|
||||
```
|
||||
|
||||
2. Add `"extends": "airbnb-base"` to your .eslintrc
|
||||
|
||||
### eslint-config-airbnb-base/legacy
|
||||
|
||||
Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`.
|
||||
|
||||
1. `npm install --save-dev eslint-config-airbnb-base eslint-plugin-import eslint`
|
||||
2. add `"extends": "airbnb-base/legacy"` to your .eslintrc
|
||||
1. Ensure packages are installed with correct version numbers by running:
|
||||
```sh
|
||||
(
|
||||
export PKG=eslint-config-airbnb-base;
|
||||
npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG"
|
||||
)
|
||||
```
|
||||
|
||||
Which produces and runs a command like:
|
||||
|
||||
```sh
|
||||
npm install --save-dev eslint-config-airbnb-base eslint@^3.0.1 eslint-plugin-import@^1.10.3
|
||||
```
|
||||
|
||||
2. Add `"extends": "airbnb-base/legacy"` to your .eslintrc
|
||||
|
||||
See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information.
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "eslint-config-airbnb-base",
|
||||
"version": "4.0.2",
|
||||
"version": "5.0.1",
|
||||
"description": "Airbnb's base JS ESLint config, following our styleguide",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"tests-only": "babel-tape-runner ./test/test-*.js",
|
||||
"prepublish": "not-in-install && (eslint-find-rules --unused && npm test) || in-install",
|
||||
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test)",
|
||||
"pretest": "npm run --silent lint",
|
||||
"test": "npm run --silent tests-only",
|
||||
"travis": "npm run --silent test"
|
||||
@@ -45,16 +45,17 @@
|
||||
},
|
||||
"homepage": "https://github.com/airbnb/javascript",
|
||||
"devDependencies": {
|
||||
"babel-tape-runner": "^1.3.1",
|
||||
"eslint": "^3.0.1",
|
||||
"eslint-find-rules": "^1.11.0",
|
||||
"eslint-plugin-import": "^1.10.3",
|
||||
"tape": "^4.6.0",
|
||||
"in-publish": "^2.0.0"
|
||||
"babel-preset-airbnb": "^2.0.0",
|
||||
"babel-tape-runner": "^2.0.1",
|
||||
"eslint": "^3.2.0",
|
||||
"eslint-find-rules": "^1.11.1",
|
||||
"eslint-plugin-import": "^1.12.0",
|
||||
"in-publish": "^2.0.0",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^3.0.1",
|
||||
"eslint-plugin-import": "^1.10.3"
|
||||
"eslint": "^3.2.0",
|
||||
"eslint-plugin-import": "^1.12.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
|
||||
@@ -26,7 +26,8 @@ module.exports = {
|
||||
'dot-notation': [2, { allowKeywords: true }],
|
||||
|
||||
// enforces consistent newlines before or after dots
|
||||
'dot-location': 0,
|
||||
// http://eslint.org/docs/rules/dot-location
|
||||
'dot-location': [2, 'property'],
|
||||
|
||||
// require the use of === and !==
|
||||
// http://eslint.org/docs/rules/eqeqeq
|
||||
@@ -46,6 +47,7 @@ module.exports = {
|
||||
'no-case-declarations': 2,
|
||||
|
||||
// disallow division operators explicitly at beginning of regular expression
|
||||
// http://eslint.org/docs/rules/no-div-regex
|
||||
'no-div-regex': 0,
|
||||
|
||||
// disallow else after a return in an if
|
||||
@@ -87,8 +89,14 @@ module.exports = {
|
||||
// disallow the use of leading or trailing decimal points in numeric literals
|
||||
'no-floating-decimal': 2,
|
||||
|
||||
// disallow the type conversions with shorter notations
|
||||
'no-implicit-coercion': 0,
|
||||
// disallow implicit type conversions
|
||||
// http://eslint.org/docs/rules/no-implicit-coercion
|
||||
'no-implicit-coercion': [0, {
|
||||
boolean: false,
|
||||
number: true,
|
||||
string: true,
|
||||
allow: [],
|
||||
}],
|
||||
|
||||
// disallow var and named functions in global scope
|
||||
// http://eslint.org/docs/rules/no-implicit-globals
|
||||
@@ -181,7 +189,10 @@ module.exports = {
|
||||
'no-unmodified-loop-condition': 0,
|
||||
|
||||
// disallow usage of expressions in statement position
|
||||
'no-unused-expressions': 2,
|
||||
'no-unused-expressions': [2, {
|
||||
allowShortCircuit: false,
|
||||
allowTernary: false,
|
||||
}],
|
||||
|
||||
// disallow unused labels
|
||||
// http://eslint.org/docs/rules/no-unused-labels
|
||||
@@ -199,7 +210,8 @@ module.exports = {
|
||||
'no-useless-escape': 2,
|
||||
|
||||
// disallow use of void operator
|
||||
'no-void': 0,
|
||||
// http://eslint.org/docs/rules/no-void
|
||||
'no-void': 2,
|
||||
|
||||
// disallow usage of configurable warning terms in comments: e.g. todo
|
||||
'no-warning-comments': [0, { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
|
||||
|
||||
@@ -37,7 +37,8 @@ module.exports = {
|
||||
'no-ex-assign': 2,
|
||||
|
||||
// disallow double-negation boolean casts in a boolean context
|
||||
'no-extra-boolean-cast': 0,
|
||||
// http://eslint.org/docs/rules/no-extra-boolean-cast
|
||||
'no-extra-boolean-cast': 2,
|
||||
|
||||
// disallow unnecessary parentheses
|
||||
// http://eslint.org/docs/rules/no-extra-parens
|
||||
@@ -79,7 +80,8 @@ module.exports = {
|
||||
'no-sparse-arrays': 2,
|
||||
|
||||
// Avoid code that looks like two expressions but is actually one
|
||||
'no-unexpected-multiline': 0,
|
||||
// http://eslint.org/docs/rules/no-unexpected-multiline
|
||||
'no-unexpected-multiline': 2,
|
||||
|
||||
// disallow unreachable statements after a return, throw, continue, or break statement
|
||||
'no-unreachable': 2,
|
||||
|
||||
@@ -24,7 +24,7 @@ module.exports = {
|
||||
'arrow-spacing': [2, { before: true, after: true }],
|
||||
|
||||
// verify super() callings in constructors
|
||||
'constructor-super': 0,
|
||||
'constructor-super': 2,
|
||||
|
||||
// enforce the spacing around the * in generator functions
|
||||
// http://eslint.org/docs/rules/generator-star-spacing
|
||||
@@ -60,7 +60,8 @@ module.exports = {
|
||||
'no-restricted-imports': 0,
|
||||
|
||||
// disallow to use this/super before super() calling in constructors.
|
||||
'no-this-before-super': 0,
|
||||
// http://eslint.org/docs/rules/no-this-before-super
|
||||
'no-this-before-super': 2,
|
||||
|
||||
// disallow useless computed property keys
|
||||
// http://eslint.org/docs/rules/no-useless-computed-key
|
||||
@@ -101,6 +102,8 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// suggest using Reflect methods where applicable
|
||||
// http://eslint.org/docs/rules/prefer-reflect
|
||||
// TODO: enable
|
||||
'prefer-reflect': 0,
|
||||
|
||||
// use rest parameters instead of arguments
|
||||
@@ -108,14 +111,16 @@ module.exports = {
|
||||
'prefer-rest-params': 2,
|
||||
|
||||
// suggest using the spread operator instead of .apply()
|
||||
'prefer-spread': 0,
|
||||
// http://eslint.org/docs/rules/prefer-spread
|
||||
'prefer-spread': 2,
|
||||
|
||||
// suggest using template literals instead of string concatenation
|
||||
// http://eslint.org/docs/rules/prefer-template
|
||||
'prefer-template': 2,
|
||||
|
||||
// disallow generator functions that do not have yield
|
||||
'require-yield': 0,
|
||||
// http://eslint.org/docs/rules/require-yield
|
||||
'require-yield': 2,
|
||||
|
||||
// enforce spacing between object rest-spread
|
||||
// http://eslint.org/docs/rules/rest-spread-spacing
|
||||
@@ -123,7 +128,11 @@ module.exports = {
|
||||
|
||||
// import sorting
|
||||
// http://eslint.org/docs/rules/sort-imports
|
||||
'sort-imports': 0,
|
||||
'sort-imports': [0, {
|
||||
ignoreCase: false,
|
||||
ignoreMemberSort: false,
|
||||
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
||||
}],
|
||||
|
||||
// enforce usage of spacing in template strings
|
||||
// http://eslint.org/docs/rules/template-curly-spacing
|
||||
|
||||
@@ -86,6 +86,7 @@ module.exports = {
|
||||
|
||||
// No Node.js builtin modules
|
||||
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
|
||||
// TODO: enable?
|
||||
'import/no-nodejs-modules': 0,
|
||||
|
||||
// Style guide:
|
||||
@@ -118,8 +119,7 @@ module.exports = {
|
||||
|
||||
// Require a newline after the last import/require in a group
|
||||
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
|
||||
// TODO: enable when https://github.com/benmosher/eslint-plugin-import/issues/386 is resolved
|
||||
'import/newline-after-import': 0,
|
||||
'import/newline-after-import': 2,
|
||||
|
||||
// Require modules with a single export to use a default export
|
||||
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
|
||||
|
||||
@@ -18,10 +18,11 @@ module.exports = {
|
||||
'no-mixed-requires': [0, false],
|
||||
|
||||
// disallow use of new operator with the require function
|
||||
'no-new-require': 0,
|
||||
'no-new-require': 2,
|
||||
|
||||
// disallow string concatenation with __dirname and __filename
|
||||
'no-path-concat': 0,
|
||||
// http://eslint.org/docs/rules/no-path-concat
|
||||
'no-path-concat': 2,
|
||||
|
||||
// disallow use of process.env
|
||||
'no-process-env': 0,
|
||||
@@ -33,6 +34,6 @@ module.exports = {
|
||||
'no-restricted-modules': 0,
|
||||
|
||||
// disallow use of synchronous methods (off by default)
|
||||
'no-sync': 0
|
||||
'no-sync': 0,
|
||||
}
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = {
|
||||
|
||||
// specify whether double or single quotes should be used in JSX attributes
|
||||
// http://eslint.org/docs/rules/jsx-quotes
|
||||
'jsx-quotes': 0,
|
||||
'jsx-quotes': [0, 'prefer-double'],
|
||||
|
||||
// enforces spacing between keys and values in object literal properties
|
||||
'key-spacing': [2, { beforeColon: false, afterColon: true }],
|
||||
@@ -68,7 +68,8 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// disallow mixed 'LF' and 'CRLF' as linebreaks
|
||||
'linebreak-style': 0,
|
||||
// http://eslint.org/docs/rules/linebreak-style
|
||||
'linebreak-style': [2, 'unix'],
|
||||
|
||||
// enforces empty lines around comments
|
||||
'lines-around-comment': 0,
|
||||
@@ -104,11 +105,16 @@ module.exports = {
|
||||
// http://eslint.org/docs/rules/max-statements-per-line
|
||||
'max-statements-per-line': [0, { max: 1 }],
|
||||
|
||||
// require multiline ternary
|
||||
// http://eslint.org/docs/rules/multiline-ternary
|
||||
'multiline-ternary': 0,
|
||||
|
||||
// require a capital letter for constructors
|
||||
'new-cap': [2, { newIsCap: true }],
|
||||
|
||||
// disallow the omission of parentheses when invoking a constructor with no arguments
|
||||
'new-parens': 0,
|
||||
// http://eslint.org/docs/rules/new-parens
|
||||
'new-parens': 2,
|
||||
|
||||
// allow/disallow an empty newline after var statement
|
||||
'newline-after-var': 0,
|
||||
@@ -125,16 +131,20 @@ module.exports = {
|
||||
'no-array-constructor': 2,
|
||||
|
||||
// disallow use of bitwise operators
|
||||
// http://eslint.org/docs/rules/no-bitwise
|
||||
// TODO: enable
|
||||
'no-bitwise': 0,
|
||||
|
||||
// disallow use of the continue statement
|
||||
'no-continue': 0,
|
||||
// http://eslint.org/docs/rules/no-continue
|
||||
'no-continue': 2,
|
||||
|
||||
// disallow comments inline after code
|
||||
'no-inline-comments': 0,
|
||||
|
||||
// disallow if as the only statement in an else block
|
||||
'no-lonely-if': 0,
|
||||
// http://eslint.org/docs/rules/no-lonely-if
|
||||
'no-lonely-if': 2,
|
||||
|
||||
// disallow un-paren'd mixes of different operators
|
||||
// http://eslint.org/docs/rules/no-mixed-operators
|
||||
@@ -181,6 +191,10 @@ module.exports = {
|
||||
// disallow space between function identifier and application
|
||||
'no-spaced-func': 2,
|
||||
|
||||
// disallow tab characters entirely
|
||||
// TODO: enable
|
||||
'no-tabs': 0,
|
||||
|
||||
// disallow the use of ternary operators
|
||||
'no-ternary': 0,
|
||||
|
||||
@@ -224,7 +238,8 @@ module.exports = {
|
||||
'one-var-declaration-per-line': [2, 'always'],
|
||||
|
||||
// require assignment operator shorthand where possible or prohibit it entirely
|
||||
'operator-assignment': 0,
|
||||
// http://eslint.org/docs/rules/operator-assignment
|
||||
'operator-assignment': [2, 'always'],
|
||||
|
||||
// enforce operators to be placed before or after line breaks
|
||||
'operator-linebreak': 0,
|
||||
@@ -266,7 +281,13 @@ module.exports = {
|
||||
'space-infix-ops': 2,
|
||||
|
||||
// Require or disallow spaces before/after unary operators
|
||||
'space-unary-ops': 0,
|
||||
// http://eslint.org/docs/rules/space-unary-ops
|
||||
'space-unary-ops': [2, {
|
||||
words: true,
|
||||
nonwords: false,
|
||||
overrides: {
|
||||
},
|
||||
}],
|
||||
|
||||
// require or disallow a space immediately following the // or /* in a comment
|
||||
'spaced-comment': [2, 'always', {
|
||||
|
||||
@@ -10,7 +10,8 @@ module.exports = {
|
||||
'no-delete-var': 2,
|
||||
|
||||
// disallow labels that share a name with a variable
|
||||
'no-label-var': 0,
|
||||
// http://eslint.org/docs/rules/no-label-var
|
||||
'no-label-var': 2,
|
||||
|
||||
// disallow specific globals
|
||||
'no-restricted-globals': 0,
|
||||
@@ -25,9 +26,10 @@ module.exports = {
|
||||
'no-undef': 2,
|
||||
|
||||
// disallow use of undefined when initializing variables
|
||||
'no-undef-init': 0,
|
||||
'no-undef-init': 2,
|
||||
|
||||
// disallow use of undefined variable
|
||||
// TODO: enable?
|
||||
'no-undefined': 0,
|
||||
|
||||
// disallow declaration of variables that are not used in the code
|
||||
|
||||
3
packages/eslint-config-airbnb/.babelrc
Normal file
3
packages/eslint-config-airbnb/.babelrc
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"presets": ["airbnb"]
|
||||
}
|
||||
@@ -12,9 +12,21 @@ We export three ESLint configurations for your usage.
|
||||
|
||||
Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires `eslint`, `eslint-plugin-import`, `eslint-plugin-react`, and `eslint-plugin-jsx-a11y`.
|
||||
|
||||
1. `npm install --save-dev eslint-config-airbnb eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y eslint`
|
||||
2. add `"extends": "airbnb"` to your .eslintrc
|
||||
1. Ensure packages are installed with correct version numbers by running:
|
||||
```sh
|
||||
(
|
||||
export PKG=eslint-config-airbnb;
|
||||
npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG"
|
||||
)
|
||||
```
|
||||
|
||||
Which produces and runs a command like:
|
||||
|
||||
```sh
|
||||
npm install --save-dev eslint-config-airbnb eslint@^2.9.0 eslint-plugin-jsx-a11y@^1.2.0 eslint-plugin-import@^1.7.0 eslint-plugin-react@^5.0.1
|
||||
```
|
||||
|
||||
2. Add `"extends": "airbnb"` to your .eslintrc
|
||||
### eslint-config-airbnb/base
|
||||
|
||||
This entry point is deprecated. See [eslint-config-airbnb-base](https://npmjs.com/eslint-config-airbnb-base).
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"tests-only": "babel-tape-runner ./test/test-*.js",
|
||||
"prepublish": "not-in-install && (eslint-find-rules --unused && npm test) || in-install",
|
||||
"prepublish": "(in-install || eslint-find-rules --unused) && (not-in-publish || npm test)",
|
||||
"pretest": "npm run --silent lint",
|
||||
"test": "npm run --silent tests-only",
|
||||
"travis": "cd ../eslint-config-airbnb-base && npm link && cd - && npm link eslint-config-airbnb-base && npm run --silent test ; npm unlink eslint-config-airbnb-base >/dev/null &"
|
||||
"travis": "cd ../eslint-config-airbnb-base && npm install && npm link && cd - && npm link eslint-config-airbnb-base && npm run --silent test ; npm unlink eslint-config-airbnb-base >/dev/null &"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -45,23 +45,27 @@
|
||||
},
|
||||
"homepage": "https://github.com/airbnb/javascript",
|
||||
"dependencies": {
|
||||
"eslint-config-airbnb-base": "^3.0.1"
|
||||
"eslint-config-airbnb-base": "^5.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-tape-runner": "^1.3.1",
|
||||
"eslint": "^2.10.2",
|
||||
"eslint-find-rules": "^1.9.2",
|
||||
"eslint-plugin-import": "^1.8.0",
|
||||
"eslint-plugin-jsx-a11y": "^1.2.2",
|
||||
"eslint-plugin-react": "^5.1.1",
|
||||
"babel-preset-airbnb": "^2.0.0",
|
||||
"babel-tape-runner": "^2.0.1",
|
||||
"eslint": "^3.2.2",
|
||||
"eslint-find-rules": "^1.11.1",
|
||||
"eslint-plugin-import": "^1.12.0",
|
||||
"eslint-plugin-jsx-a11y": "^2.0.1",
|
||||
"eslint-plugin-react": "^6.0.0",
|
||||
"in-publish": "^2.0.0",
|
||||
"react": ">= 0.13.0",
|
||||
"tape": "^4.5.1",
|
||||
"in-publish": "^2.0.0"
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^2.10.2",
|
||||
"eslint-plugin-jsx-a11y": "^1.2.2",
|
||||
"eslint-plugin-import": "^1.8.0",
|
||||
"eslint-plugin-react": "^5.1.1"
|
||||
"eslint": "^3.2.2",
|
||||
"eslint-plugin-jsx-a11y": "^2.0.1",
|
||||
"eslint-plugin-import": "^1.12.0",
|
||||
"eslint-plugin-react": "^6.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,25 +12,21 @@ module.exports = {
|
||||
'jsx-a11y/aria-role': 2,
|
||||
|
||||
// Enforce all aria-* props are valid.
|
||||
// TODO: enable
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-props.md
|
||||
'jsx-a11y/aria-props': 0,
|
||||
'jsx-a11y/aria-props': 2,
|
||||
|
||||
// Enforce ARIA state and property values are valid.
|
||||
// TODO: enable
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-proptypes.md
|
||||
'jsx-a11y/aria-proptypes': 0,
|
||||
'jsx-a11y/aria-proptypes': 2,
|
||||
|
||||
// Enforce that elements that do not support ARIA roles, states, and
|
||||
// properties do not have those attributes.
|
||||
// TODO: enable
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md
|
||||
'jsx-a11y/aria-unsupported-elements': 0,
|
||||
'jsx-a11y/aria-unsupported-elements': 2,
|
||||
|
||||
// disallow href "#"
|
||||
// TODO: enable
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md
|
||||
'jsx-a11y/href-no-hash': 0,
|
||||
'jsx-a11y/href-no-hash': [2, ['a']],
|
||||
|
||||
// Require <img> to have a non-empty `alt` prop, or role="presentation"
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-has-alt.md
|
||||
@@ -41,12 +37,11 @@ module.exports = {
|
||||
'jsx-a11y/img-redundant-alt': 2,
|
||||
|
||||
// require that JSX labels use "htmlFor"
|
||||
// TODO: enable
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
|
||||
'jsx-a11y/label-has-for': 0,
|
||||
'jsx-a11y/label-has-for': [2, ['label']],
|
||||
|
||||
// require that mouseover/out come with focus/blur, for keyboard-only users
|
||||
// TODO: enable?
|
||||
// TODO: evaluate
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md
|
||||
'jsx-a11y/mouse-events-have-key-events': 0,
|
||||
|
||||
@@ -69,19 +64,37 @@ module.exports = {
|
||||
|
||||
// Enforce that elements with ARIA roles must have all required attributes
|
||||
// for that role.
|
||||
// TODO: enable
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-has-required-aria-props.md
|
||||
'jsx-a11y/role-has-required-aria-props': 0,
|
||||
'jsx-a11y/role-has-required-aria-props': 2,
|
||||
|
||||
// Enforce that elements with explicit or implicit roles defined contain
|
||||
// only aria-* properties supported by that role.
|
||||
// TODO: enable
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/role-supports-aria-props.md
|
||||
'jsx-a11y/role-supports-aria-props': 0,
|
||||
'jsx-a11y/role-supports-aria-props': 2,
|
||||
|
||||
// Enforce tabIndex value is not greater than zero.
|
||||
// TODO: evaluate
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/tabindex-no-positive.md
|
||||
'jsx-a11y/tabindex-no-positive': 0,
|
||||
|
||||
// ensure <hX> tags have content and are not aria-hidden
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
|
||||
'jsx-a11y/heading-has-content': [2, ['']],
|
||||
|
||||
// require HTML elements to have a "lang" prop
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md
|
||||
'jsx-a11y/html-has-lang': 2,
|
||||
|
||||
// require HTML element's lang prop to be valid
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/lang.md
|
||||
'jsx-a11y/lang': 2,
|
||||
|
||||
// prevent marquee elements
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-marquee.md
|
||||
'jsx-a11y/no-marquee': 2,
|
||||
|
||||
// only allow <th> to have the "scope" attr
|
||||
// https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md
|
||||
'jsx-a11y/scope': 2,
|
||||
},
|
||||
};
|
||||
|
||||
52
packages/eslint-config-airbnb/rules/react.js
vendored
52
packages/eslint-config-airbnb/rules/react.js
vendored
@@ -14,7 +14,7 @@ module.exports = {
|
||||
// View link below for react rules documentation
|
||||
// https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
|
||||
rules: {
|
||||
// specify whether double or single quotes should be used in JSX attributes
|
||||
// Specify whether double or single quotes should be used in JSX attributes
|
||||
// http://eslint.org/docs/rules/jsx-quotes
|
||||
'jsx-quotes': [2, 'prefer-double'],
|
||||
|
||||
@@ -89,9 +89,10 @@ module.exports = {
|
||||
'react/sort-prop-types': [0, {
|
||||
ignoreCase: false,
|
||||
callbacksLast: false,
|
||||
requiredFirst: false,
|
||||
}],
|
||||
|
||||
// deprecated in favor of react/jsx-sort-props
|
||||
// Deprecated in favor of react/jsx-sort-props
|
||||
'react/jsx-sort-prop-types': 0,
|
||||
|
||||
// Enforce props alphabetical sorting
|
||||
@@ -99,11 +100,13 @@ module.exports = {
|
||||
'react/jsx-sort-props': [0, {
|
||||
ignoreCase: false,
|
||||
callbacksLast: false,
|
||||
shorthandFirst: false,
|
||||
shorthandLast: false,
|
||||
}],
|
||||
|
||||
// Prevent React to be incorrectly marked as unused
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
|
||||
'react/jsx-uses-react': [2, { pragma: 'React' }],
|
||||
'react/jsx-uses-react': [2],
|
||||
|
||||
// Prevent variables used in JSX to be incorrectly marked as unused
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
|
||||
@@ -115,15 +118,15 @@ module.exports = {
|
||||
|
||||
// Prevent usage of deprecated methods
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
|
||||
'react/no-deprecated': [1, { react: '0.14.0' }],
|
||||
'react/no-deprecated': [2],
|
||||
|
||||
// Prevent usage of setState in componentDidMount
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
|
||||
'react/no-did-mount-set-state': [2, 'allow-in-func'],
|
||||
'react/no-did-mount-set-state': [2],
|
||||
|
||||
// Prevent usage of setState in componentDidUpdate
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
|
||||
'react/no-did-update-set-state': [2, 'allow-in-func'],
|
||||
'react/no-did-update-set-state': [2],
|
||||
|
||||
// Prevent direct mutation of this.state
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-direct-mutation-state.md
|
||||
@@ -167,7 +170,7 @@ module.exports = {
|
||||
|
||||
// Restrict file extensions that may be required
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md
|
||||
'react/require-extension': [0, { extensions: ['.jsx'] }],
|
||||
'react/require-extension': [2, { extensions: ['.jsx', '.js'] }],
|
||||
|
||||
// Require render() methods to return something
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md
|
||||
@@ -196,29 +199,50 @@ module.exports = {
|
||||
}],
|
||||
|
||||
// Prevent missing parentheses around multilines JSX
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md
|
||||
'react/wrap-multilines': [2, {
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-wrap-multilines.md
|
||||
'react/jsx-wrap-multilines': [2, {
|
||||
declaration: true,
|
||||
assignment: true,
|
||||
return: true
|
||||
}],
|
||||
'react/wrap-multilines': 0, // deprecated version
|
||||
|
||||
// Require that the first prop in a JSX element be on a new line when the element is multiline
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-first-prop-new-line.md
|
||||
'react/jsx-first-prop-new-line': [2, 'multiline'],
|
||||
|
||||
// enforce spacing around jsx equals signs
|
||||
// Enforce spacing around jsx equals signs
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-equals-spacing.md
|
||||
'react/jsx-equals-spacing': [2, 'never'],
|
||||
|
||||
// enforce JSX indentation
|
||||
// Enforce JSX indentation
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent.md
|
||||
'react/jsx-indent': [2, 2],
|
||||
|
||||
// disallow target="_blank" on links
|
||||
// Disallow target="_blank" on links
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md
|
||||
// TODO: enable
|
||||
'react/jsx-no-target-blank': 0
|
||||
'react/jsx-no-target-blank': 2,
|
||||
|
||||
// only .jsx files may have JSX
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-filename-extension.md
|
||||
'react/jsx-filename-extension': [2, { extensions: ['.jsx'] }],
|
||||
|
||||
// prevent accidental JS comments from being injected into JSX as text
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-comment-textnodes.md
|
||||
'react/jsx-no-comment-textnodes': 2,
|
||||
'react/no-comment-textnodes': 0, // deprecated version
|
||||
|
||||
// disallow using React.render/ReactDOM.render's return value
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-render-return-value.md
|
||||
'react/no-render-return-value': 2,
|
||||
|
||||
// require a shouldComponentUpdate method, or PureRenderMixin
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-optimization.md
|
||||
'react/require-optimization': [0, { allowDecorators: [] }],
|
||||
|
||||
// warn against using findDOMNode()
|
||||
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-find-dom-node.md
|
||||
'react/no-find-dom-node': 2,
|
||||
},
|
||||
|
||||
settings: {
|
||||
|
||||
@@ -9,9 +9,6 @@ const cli = new CLIEngine({
|
||||
baseConfig: eslintrc,
|
||||
|
||||
rules: {
|
||||
// This rule fails when executing on text.
|
||||
indent: 0,
|
||||
|
||||
// It is okay to import devDependencies in tests.
|
||||
'import/no-extraneous-dependencies': [2, { devDependencies: true }],
|
||||
},
|
||||
@@ -27,6 +24,7 @@ function lint(text) {
|
||||
function wrapComponent(body) {
|
||||
return `
|
||||
import React from 'react';
|
||||
|
||||
export default class MyComponent extends React.Component {
|
||||
/* eslint no-empty-function: 0 */
|
||||
${body}
|
||||
|
||||
@@ -101,7 +101,32 @@
|
||||
// good
|
||||
import Footer from './Footer';
|
||||
```
|
||||
- **Higher-order Component Naming**: Use a composite of the higher-order component's name and the passed-in component's name as the `displayName` on the generated component. For example, the higher-order component `withFoo()`, when passed a component `Bar` should produce a component with a `displayName` of `withFoo(Bar)`.
|
||||
|
||||
> Why? A component's `displayName` may be used by developer tools or in error messages, and having a value that clearly expresses this relationship helps people understand what is happening.
|
||||
|
||||
```jsx
|
||||
// bad
|
||||
export default function withFoo(WrappedComponent) {
|
||||
return function WithFoo(props) {
|
||||
return <WrappedComponent {...props} foo />;
|
||||
}
|
||||
}
|
||||
|
||||
// good
|
||||
export default function withFoo(WrappedComponent) {
|
||||
function WithFoo(props) {
|
||||
return <WrappedComponent {...props} foo />;
|
||||
}
|
||||
|
||||
const wrappedComponentName = WrappedComponent.displayName
|
||||
|| WrappedComponent.name
|
||||
|| 'Component';
|
||||
|
||||
WithFoo.displayName = `withFoo(${wrappedComponentName})`;
|
||||
return WithFoo;
|
||||
}
|
||||
```
|
||||
## Declaration
|
||||
|
||||
- Do not use `displayName` for naming components. Instead, name the component by reference.
|
||||
@@ -149,7 +174,7 @@
|
||||
|
||||
- Always use double quotes (`"`) for JSX attributes, but single quotes for all other JS. eslint: [`jsx-quotes`](http://eslint.org/docs/rules/jsx-quotes)
|
||||
|
||||
> Why? JSX attributes [can't contain escaped quotes](http://eslint.org/docs/rules/jsx-quotes), so double quotes make conjunctions like `"don't"` easier to type.
|
||||
> Why? JSX attributes [can't contain escaped quotes](http://eslint.org/docs/rules/jsx-quotes), so double quotes make contractions like `"don't"` easier to type.
|
||||
> Regular HTML attributes also typically use double quotes instead of single, so JSX attributes mirror this convention.
|
||||
|
||||
```jsx
|
||||
@@ -549,5 +574,6 @@
|
||||
-  **Chinese (Simplified)**: [JasonBoy/javascript](https://github.com/JasonBoy/javascript/tree/master/react)
|
||||
-  **Polish**: [pietraszekl/javascript](https://github.com/pietraszekl/javascript/tree/master/react)
|
||||
-  **Korean**: [apple77y/javascript](https://github.com/apple77y/javascript/tree/master/react)
|
||||
-  **Portuguese**: [ronal2do/javascript](https://github.com/ronal2do/airbnb-react-styleguide)
|
||||
|
||||
**[⬆ back to top](#table-of-contents)**
|
||||
|
||||
Reference in New Issue
Block a user