Skip to content

Commit fde9c12

Browse files
committed
Merge pull request airbnb#479 from justjake/jake/some-small-issues
Modularize eslintrc, add tests
2 parents 425e1f9 + 2d90ebf commit fde9c12

File tree

9 files changed

+356
-221
lines changed

9 files changed

+356
-221
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "airbnb",
3+
"rules": {
4+
// disable requiring trailing commas because it might be nice to revert to
5+
// being JSON at some point, and I don't want to make big changes now.
6+
"comma-dangle": 0,
7+
// disabled because I find it tedious to write tests while following this
8+
// rule
9+
"no-shadow": 0
10+
}
11+
}

packages/eslint-config-airbnb/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,26 @@ This package provides Airbnb's .eslintrc as an extensible shared config.
44

55
## Usage
66

7+
### With React Style
8+
79
1. `npm install --save-dev eslint-config-airbnb babel-eslint eslint-plugin-react`
8-
2. add `"extends": "eslint-config-airbnb"` to your .eslintrc
10+
2. add `"extends": "airbnb"` to your .eslintrc
11+
12+
### Without React Style
13+
14+
1. `npm install --save-dev eslint-config-airbnb babel-eslint `
15+
2. add `"extends": "airbnb/base"` to your .eslintrc
916

1017
See [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript) and
1118
the [ESlint config docs](http://eslint.org/docs/user-guide/configuring#extending-configuration-files)
1219
for more information.
20+
21+
## Improving this config
22+
23+
Consider adding test cases if you're making complicated rules changes, like
24+
anything involving regexes. Perhaps in a distant future, we could use literate
25+
programming to structure our README as test cases for our .eslintrc?
26+
27+
You can run tests with `npm test`.
28+
29+
You can make sure this module lints with itself using `npm run lint`.
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
module.exports = {
2+
'parser': 'babel-eslint', // https://github.com/babel/babel-eslint
3+
'env': { // http://eslint.org/docs/user-guide/configuring.html#specifying-environments
4+
'browser': true, // browser global variables
5+
'node': true // Node.js global variables and Node.js-specific rules
6+
},
7+
'ecmaFeatures': {
8+
'arrowFunctions': true,
9+
'blockBindings': true,
10+
'classes': true,
11+
'defaultParams': true,
12+
'destructuring': true,
13+
'forOf': true,
14+
'generators': false,
15+
'modules': true,
16+
'objectLiteralComputedProperties': true,
17+
'objectLiteralDuplicateProperties': false,
18+
'objectLiteralShorthandMethods': true,
19+
'objectLiteralShorthandProperties': true,
20+
'spread': true,
21+
'superInFunctions': true,
22+
'templateStrings': true,
23+
'jsx': true
24+
},
25+
'rules': {
26+
/**
27+
* Strict mode
28+
*/
29+
// babel inserts 'use strict'; for us
30+
'strict': [2, 'never'], // http://eslint.org/docs/rules/strict
31+
32+
/**
33+
* ES6
34+
*/
35+
'no-var': 2, // http://eslint.org/docs/rules/no-var
36+
'prefer-const': 2, // http://eslint.org/docs/rules/prefer-const
37+
38+
/**
39+
* Variables
40+
*/
41+
'no-shadow': 2, // http://eslint.org/docs/rules/no-shadow
42+
'no-shadow-restricted-names': 2, // http://eslint.org/docs/rules/no-shadow-restricted-names
43+
'no-unused-vars': [2, { // http://eslint.org/docs/rules/no-unused-vars
44+
'vars': 'local',
45+
'args': 'after-used'
46+
}],
47+
'no-use-before-define': 2, // http://eslint.org/docs/rules/no-use-before-define
48+
49+
/**
50+
* Possible errors
51+
*/
52+
'comma-dangle': [2, 'always-multiline'], // http://eslint.org/docs/rules/comma-dangle
53+
'no-cond-assign': [2, 'always'], // http://eslint.org/docs/rules/no-cond-assign
54+
'no-console': 1, // http://eslint.org/docs/rules/no-console
55+
'no-debugger': 1, // http://eslint.org/docs/rules/no-debugger
56+
'no-alert': 1, // http://eslint.org/docs/rules/no-alert
57+
'no-constant-condition': 1, // http://eslint.org/docs/rules/no-constant-condition
58+
'no-dupe-keys': 2, // http://eslint.org/docs/rules/no-dupe-keys
59+
'no-duplicate-case': 2, // http://eslint.org/docs/rules/no-duplicate-case
60+
'no-empty': 2, // http://eslint.org/docs/rules/no-empty
61+
'no-ex-assign': 2, // http://eslint.org/docs/rules/no-ex-assign
62+
'no-extra-boolean-cast': 0, // http://eslint.org/docs/rules/no-extra-boolean-cast
63+
'no-extra-semi': 2, // http://eslint.org/docs/rules/no-extra-semi
64+
'no-func-assign': 2, // http://eslint.org/docs/rules/no-func-assign
65+
'no-inner-declarations': 2, // http://eslint.org/docs/rules/no-inner-declarations
66+
'no-invalid-regexp': 2, // http://eslint.org/docs/rules/no-invalid-regexp
67+
'no-irregular-whitespace': 2, // http://eslint.org/docs/rules/no-irregular-whitespace
68+
'no-obj-calls': 2, // http://eslint.org/docs/rules/no-obj-calls
69+
'no-sparse-arrays': 2, // http://eslint.org/docs/rules/no-sparse-arrays
70+
'no-unreachable': 2, // http://eslint.org/docs/rules/no-unreachable
71+
'use-isnan': 2, // http://eslint.org/docs/rules/use-isnan
72+
'block-scoped-var': 2, // http://eslint.org/docs/rules/block-scoped-var
73+
74+
/**
75+
* Best practices
76+
*/
77+
'consistent-return': 2, // http://eslint.org/docs/rules/consistent-return
78+
'curly': [2, 'multi-line'], // http://eslint.org/docs/rules/curly
79+
'default-case': 2, // http://eslint.org/docs/rules/default-case
80+
'dot-notation': [2, { // http://eslint.org/docs/rules/dot-notation
81+
'allowKeywords': true
82+
}],
83+
'eqeqeq': 2, // http://eslint.org/docs/rules/eqeqeq
84+
'guard-for-in': 2, // http://eslint.org/docs/rules/guard-for-in
85+
'no-caller': 2, // http://eslint.org/docs/rules/no-caller
86+
'no-else-return': 2, // http://eslint.org/docs/rules/no-else-return
87+
'no-eq-null': 2, // http://eslint.org/docs/rules/no-eq-null
88+
'no-eval': 2, // http://eslint.org/docs/rules/no-eval
89+
'no-extend-native': 2, // http://eslint.org/docs/rules/no-extend-native
90+
'no-extra-bind': 2, // http://eslint.org/docs/rules/no-extra-bind
91+
'no-fallthrough': 2, // http://eslint.org/docs/rules/no-fallthrough
92+
'no-floating-decimal': 2, // http://eslint.org/docs/rules/no-floating-decimal
93+
'no-implied-eval': 2, // http://eslint.org/docs/rules/no-implied-eval
94+
'no-lone-blocks': 2, // http://eslint.org/docs/rules/no-lone-blocks
95+
'no-loop-func': 2, // http://eslint.org/docs/rules/no-loop-func
96+
'no-multi-str': 2, // http://eslint.org/docs/rules/no-multi-str
97+
'no-native-reassign': 2, // http://eslint.org/docs/rules/no-native-reassign
98+
'no-new': 2, // http://eslint.org/docs/rules/no-new
99+
'no-new-func': 2, // http://eslint.org/docs/rules/no-new-func
100+
'no-new-wrappers': 2, // http://eslint.org/docs/rules/no-new-wrappers
101+
'no-octal': 2, // http://eslint.org/docs/rules/no-octal
102+
'no-octal-escape': 2, // http://eslint.org/docs/rules/no-octal-escape
103+
'no-param-reassign': 2, // http://eslint.org/docs/rules/no-param-reassign
104+
'no-proto': 2, // http://eslint.org/docs/rules/no-proto
105+
'no-redeclare': 2, // http://eslint.org/docs/rules/no-redeclare
106+
'no-return-assign': 2, // http://eslint.org/docs/rules/no-return-assign
107+
'no-script-url': 2, // http://eslint.org/docs/rules/no-script-url
108+
'no-self-compare': 2, // http://eslint.org/docs/rules/no-self-compare
109+
'no-sequences': 2, // http://eslint.org/docs/rules/no-sequences
110+
'no-throw-literal': 2, // http://eslint.org/docs/rules/no-throw-literal
111+
'no-with': 2, // http://eslint.org/docs/rules/no-with
112+
'radix': 2, // http://eslint.org/docs/rules/radix
113+
'vars-on-top': 2, // http://eslint.org/docs/rules/vars-on-top
114+
'wrap-iife': [2, 'any'], // http://eslint.org/docs/rules/wrap-iife
115+
'yoda': 2, // http://eslint.org/docs/rules/yoda
116+
117+
/**
118+
* Style
119+
*/
120+
'indent': [2, 2], // http://eslint.org/docs/rules/indent
121+
'brace-style': [
122+
2, // http://eslint.org/docs/rules/brace-style
123+
'1tbs', {
124+
'allowSingleLine': true
125+
}
126+
],
127+
'quotes': [
128+
2, 'single', 'avoid-escape' // http://eslint.org/docs/rules/quotes
129+
],
130+
'camelcase': [2, { // http://eslint.org/docs/rules/camelcase
131+
'properties': 'never'
132+
}],
133+
'comma-spacing': [2, { // http://eslint.org/docs/rules/comma-spacing
134+
'before': false,
135+
'after': true
136+
}],
137+
'comma-style': [2, 'last'], // http://eslint.org/docs/rules/comma-style
138+
'eol-last': 2, // http://eslint.org/docs/rules/eol-last
139+
'func-names': 1, // http://eslint.org/docs/rules/func-names
140+
'key-spacing': [2, { // http://eslint.org/docs/rules/key-spacing
141+
'beforeColon': false,
142+
'afterColon': true
143+
}],
144+
'new-cap': [2, { // http://eslint.org/docs/rules/new-cap
145+
'newIsCap': true
146+
}],
147+
'no-multiple-empty-lines': [2, { // http://eslint.org/docs/rules/no-multiple-empty-lines
148+
'max': 2
149+
}],
150+
'no-nested-ternary': 2, // http://eslint.org/docs/rules/no-nested-ternary
151+
'no-new-object': 2, // http://eslint.org/docs/rules/no-new-object
152+
'no-spaced-func': 2, // http://eslint.org/docs/rules/no-spaced-func
153+
'no-trailing-spaces': 2, // http://eslint.org/docs/rules/no-trailing-spaces
154+
'no-extra-parens': [2, 'functions'], // http://eslint.org/docs/rules/no-extra-parens
155+
'no-underscore-dangle': 0, // http://eslint.org/docs/rules/no-underscore-dangle
156+
'one-var': [2, 'never'], // http://eslint.org/docs/rules/one-var
157+
'padded-blocks': [2, 'never'], // http://eslint.org/docs/rules/padded-blocks
158+
'semi': [2, 'always'], // http://eslint.org/docs/rules/semi
159+
'semi-spacing': [2, { // http://eslint.org/docs/rules/semi-spacing
160+
'before': false,
161+
'after': true
162+
}],
163+
'space-after-keywords': 2, // http://eslint.org/docs/rules/space-after-keywords
164+
'space-before-blocks': 2, // http://eslint.org/docs/rules/space-before-blocks
165+
'space-before-function-paren': [2, 'never'], // http://eslint.org/docs/rules/space-before-function-paren
166+
'space-infix-ops': 2, // http://eslint.org/docs/rules/space-infix-ops
167+
'space-return-throw-case': 2, // http://eslint.org/docs/rules/space-return-throw-case
168+
'spaced-comment': [2, 'always', {// http://eslint.org/docs/rules/spaced-comment
169+
'exceptions': ['-', '+'],
170+
'markers': ['=', '!'] // space here to support sprockets directives
171+
}],
172+
}
173+
};

0 commit comments

Comments
 (0)