Skip to content

Commit 1de08c3

Browse files
committed
add eslint
1 parent a2678bb commit 1de08c3

File tree

5 files changed

+229
-0
lines changed

5 files changed

+229
-0
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/lib
2+
/node_modules

.eslintrc

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
{
2+
"parser": "babel-eslint",
3+
"plugins": [
4+
"babel",
5+
"flow-vars",
6+
"react"
7+
],
8+
"env": {
9+
"browser": true,
10+
"node": true
11+
},
12+
"globals": {
13+
"Map": false
14+
},
15+
"rules": {
16+
"no-cond-assign": 1, // disallow assignment in conditional expressions
17+
"no-console": 0, // disallow use of console: should use nuclide-logging instead
18+
"no-constant-condition": 1, // disallow use of constant expressions in conditions
19+
"no-control-regex": 1, // disallow control characters in regular expressions
20+
"no-debugger": 1, // disallow use of debugger
21+
"no-dupe-keys": 1, // disallow duplicate keys when creating object literals
22+
"no-dupe-args": 1, // disallow duplicate arguments in functions
23+
"no-duplicate-case": 1, // disallow a duplicate case label
24+
"no-empty": 0, // disallow empty statements
25+
"no-empty-character-class": 1, // disallow the use of empty character classes in regular expressions
26+
"no-ex-assign": 1, // disallow assigning to the exception in a catch block
27+
"no-extra-boolean-cast": 1, // disallow double-negation boolean casts in a boolean context
28+
"no-extra-semi": 1, // disallow unnecessary semicolons
29+
"no-func-assign": 1, // disallow overwriting functions written as function declarations
30+
"no-inner-declarations": 0, // disallow function or variable declarations in nested blocks
31+
"no-invalid-regexp": 1, // disallow invalid regular expression strings in the RegExp constructor
32+
"no-negated-in-lhs": 1, // disallow negation of the left operand of an in expression
33+
"no-obj-calls": 1, // disallow the use of object properties of the global object (Math and JSON) as functions
34+
"no-regex-spaces": 1, // disallow multiple spaces in a regular expression literal
35+
"no-reserved-keys": 0, // disallow reserved words being used as object literal keys
36+
"no-sparse-arrays": 1, // disallow sparse arrays
37+
"no-unreachable": 1, // disallow unreachable statements after a return, throw, continue, or break statement
38+
"use-isnan": 1, // disallow comparisons with the value NaN
39+
"valid-jsdoc": 0, // Ensure JSDoc comments are valid
40+
"valid-typeof": 1, // Ensure that the results of typeof are compared against a valid string
41+
42+
// Best Practices (designed to prevent you from making mistakes)
43+
44+
"block-scoped-var": 0, // treat var statements as if they were block scoped
45+
"complexity": 0, // specify the maximum cyclomatic complexity allowed in a program
46+
"consistent-return": 0, // require return statements to either always or never specify values
47+
"curly": 1, // specify curly brace conventions for all control statements
48+
"default-case": 0, // require default case in switch statements
49+
"dot-notation": 0, // dot notation encouraged except for foreign properties that cannot be renamed (i.e., Closure Compiler rules)
50+
"eqeqeq": [1, "allow-null"], // require the use of === and !==
51+
"guard-for-in": 1, // make sure for-in loops have an if statement
52+
"no-alert": 1, // disallow the use of alert, confirm, and prompt
53+
"no-caller": 1, // disallow use of arguments.caller or arguments.callee
54+
"no-div-regex": 1, // disallow division operators explicitly at beginning of regular expression
55+
"no-else-return": 0, // disallow else after a return in an if
56+
"no-eq-null": 0, // disallow comparisons to null without a type-checking operator
57+
"no-eval": 1, // disallow use of eval()
58+
"no-extend-native": 1, // disallow adding to native types
59+
"no-extra-bind": 1, // disallow unnecessary function binding
60+
"no-fallthrough": 1, // disallow fallthrough of case statements
61+
"no-floating-decimal": 1, // disallow the use of leading or trailing decimal points in numeric literals
62+
"no-implied-eval": 1, // disallow use of eval()-like methods
63+
"no-labels": 1, // disallow use of labeled statements
64+
"no-iterator": 1, // disallow usage of __iterator__ property
65+
"no-lone-blocks": 1, // disallow unnecessary nested blocks
66+
"no-loop-func": 0, // disallow creation of functions within loops
67+
"no-multi-str": 0, // disallow use of multiline strings
68+
"no-native-reassign": 0, // disallow reassignments of native objects
69+
"no-new": 1, // disallow use of new operator when not part of the assignment or comparison
70+
"no-new-func": 1, // disallow use of new operator for Function object
71+
"no-new-wrappers": 1, // disallows creating new instances of String,Number, and Boolean
72+
"no-octal": 1, // disallow use of octal literals
73+
"no-octal-escape": 1, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
74+
"no-proto": 1, // disallow usage of __proto__ property
75+
"no-redeclare": 1, // disallow declaring the same variable more then once
76+
"no-return-assign": 1, // disallow use of assignment in return statement
77+
"no-script-url": 1, // disallow use of javascript: urls.
78+
"no-self-compare": 1, // disallow comparisons where both sides are exactly the same
79+
"no-sequences": 1, // disallow use of comma operator
80+
"no-unused-expressions": 0, // disallow usage of expressions in statement position
81+
"no-void": 1, // disallow use of void operator
82+
"no-warning-comments": 0, // disallow usage of configurable warning terms in comments e.g. TODO or FIXME
83+
"no-with": 1, // disallow use of the with statement
84+
"radix": 1, // require use of the second argument for parseInt()
85+
"vars-on-top": 0, // requires to declare all vars on top of their containing scope
86+
"wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses
87+
"yoda": 1, // require or disallow Yoda conditions
88+
"strict": 0, // this rule conflicts with 'use-babel' so we'll just disable it
89+
90+
// Variables
91+
92+
"no-catch-shadow": 1, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
93+
"no-delete-var": 1, // disallow deletion of variables
94+
"no-label-var": 1, // disallow labels that share a name with a variable
95+
"no-shadow": 0, // disallow declaration of variables already declared in the outer scope
96+
"no-shadow-restricted-names": 1, // disallow shadowing of names such as arguments
97+
"no-undef": 1, // disallow undeclared variables
98+
"no-undefined": 0, // disallow use of undefined variable
99+
"no-undef-init": 0, // disallow use of undefined when initializing variables
100+
"no-unused-vars": 1, // disallow declaration of variables that are not used in the code
101+
"no-use-before-define": 0, // disallow use of variables before they are defined
102+
103+
// Node.js
104+
105+
"handle-callback-err": 1, // enforces error handling in callbacks
106+
"no-mixed-requires": 1, // disallow mixing regular variable and require declarations
107+
"no-new-require": 1, // disallow use of new operator with the require function
108+
"no-path-concat": 1, // disallow string concatenation with __dirname and __filename
109+
"no-process-exit": 0, // disallow process.exit()
110+
"no-restricted-modules": 1, // restrict usage of specified node modules
111+
"no-sync": 0, // disallow use of synchronous methods
112+
113+
// React (eslint-plugin-react)
114+
115+
"jsx-quotes": [1, "prefer-double"], // <Foo bar="x" /> not <Foo bar='x' />
116+
"react/jsx-curly-spacing": [ // Enforce or disallow spaces inside of curly braces in JSX attributes
117+
1, "never"
118+
],
119+
"react/jsx-no-undef": 1, // Disallow undeclared variables in JSX
120+
"react/jsx-uses-react": 1, // Prevent React to be incorrectly marked as unused
121+
"react/jsx-uses-vars": 1, // Prevent variables used in JSX to be incorrectly marked as unused
122+
"react/no-unknown-property": 1, // Prevent usage of unknown DOM property
123+
"react/prop-types": 1, // Prevent missing props validation in a React component definition
124+
"react/react-in-jsx-scope": 2, // Prevent missing React when using JSX
125+
126+
// Stylistic (these rules are purely matters of style and are quite subjective)
127+
128+
"key-spacing": 1, // require space after colon `{a: 1}`
129+
"comma-spacing": 1, // require space after comma `var a, b;`
130+
"no-multi-spaces": 1, // don't allow more spaces than necessary
131+
"brace-style": [ // enforce one true brace style
132+
1, "1tbs", {
133+
"allowSingleLine": false
134+
}
135+
],
136+
"camelcase": [ // require camel case names
137+
1, {"properties": "never"}
138+
],
139+
"consistent-this": [1, "self"], // enforces consistent naming when capturing the current execution context
140+
"eol-last": 1, // enforce newline at the end of file, with no multiple empty lines
141+
"func-names": 0, // require function expressions to have a name
142+
"func-style": 0, // enforces use of function declarations or expressions
143+
"new-cap": 0, // require a capital letter for constructors
144+
"new-parens": 1, // disallow the omission of parentheses when invoking a constructor with no arguments
145+
"no-nested-ternary": 0, // disallow nested ternary expressions
146+
"no-array-constructor": 1, // disallow use of the Array constructor
147+
"no-lonely-if": 0, // disallow if as the only statement in an else block
148+
"no-new-object": 1, // disallow use of the Object constructor
149+
"no-spaced-func": 1, // disallow space between function identifier and application
150+
"semi-spacing": 1, // disallow space before semicolon
151+
"no-ternary": 0, // disallow the use of ternary operators
152+
"no-trailing-spaces": 1, // disallow trailing whitespace at the end of lines
153+
"no-underscore-dangle": 0, // disallow dangling underscores in identifiers
154+
"no-extra-parens": [1, "functions"], // disallow wrapping of non-IIFE statements in parens
155+
"no-mixed-spaces-and-tabs": 1, // disallow mixed spaces and tabs for indentation
156+
"indent": [1, 4, {"SwitchCase": 1}], // indentation should be four spaces
157+
"quotes": [ // enforce single quotes, allow double to avoid escaping ("don't escape" instead of 'don\'t escape')
158+
1, "single", "avoid-escape"
159+
],
160+
"quote-props": [1, "as-needed"], // require quotes around object literal property names
161+
"semi": 1, // require or disallow use of semicolons instead of ASI
162+
"sort-vars": 0, // sort variables within the same declaration block
163+
"keyword-spacing": 1, // require a space around certain keywords
164+
"space-before-blocks": 1, // require a space before blocks
165+
"space-before-function-paren": [ // disallow a space before function parenthesis
166+
1, "never"
167+
],
168+
"object-curly-spacing": [ // disallow spaces inside of curly braces in object literals
169+
1, "never"
170+
],
171+
"array-bracket-spacing": [ // disallow spaces inside of curly braces in array literals
172+
1, "never"
173+
],
174+
"space-in-parens": 1, // require or disallow spaces inside parentheses
175+
"space-infix-ops": 1, // require spaces around operators
176+
"space-unary-ops": 1, // require a space around word operators such as typeof
177+
"max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested
178+
// "one-var": [1, "never"], // allow just one var statement per function
179+
"wrap-regex": 0, // require regex literals to be wrapped in parentheses
180+
181+
// ECMAScript 6/7 (2015 and above)
182+
"arrow-parens": 1, // require parens in arrow function arguments
183+
"arrow-spacing": 1, // require space before/after arrow function's arrow (fixable)
184+
"constructor-super": 1, // verify calls of super() in constructors
185+
"generator-star-spacing": 0, // enforce spacing around the * in generator functions (fixable)
186+
"no-class-assign": 1, // disallow modifying variables of class declarations
187+
"no-const-assign": 1, // disallow modifying variables that are declared using const
188+
"no-dupe-class-members": 1, // disallow duplicate name in class members
189+
"no-this-before-super": 1, // disallow use of this/super before calling super() in constructors.
190+
"no-var": 0, // require let or const instead of var
191+
"object-shorthand": 0, // require method and property shorthand syntax for object literals
192+
"prefer-arrow-callback": 1, // suggest using arrow functions as callbacks
193+
"prefer-const": 0, // suggest using const declaration for variables that are never modified after declared
194+
"prefer-reflect": 0, // suggest using Reflect methods where applicable
195+
"prefer-spread": 0, // suggest using the spread operator instead of .apply().
196+
"prefer-template": 0, // suggest using template literals instead of strings concatenation
197+
"require-yield": 0, // disallow generator functions that do not have yield
198+
"babel/no-await-in-loop": 1, // async inside a loop will run operations in serial, when often the desired behavior is to do do in parallel
199+
200+
// Legacy (included for compatibility with JSHint and JSLint. While the names of the rules may not match up with the JSHint/JSLint counterpart, the functionality is the same)
201+
202+
"max-depth": 0, // specify the maximum depth that blocks can be nested
203+
//"max-len": [ // specify the maximum length of a line in your program [warning level, max line length, number of characters to treat a tab as]
204+
// 1, 100, 2, {
205+
// "ignoreUrls": true,
206+
// "ignorePattern": "^\\s*(import\\s[^{]+from|(var|const|let)\\s[^{]+=\\s*require\\s*\\()"
207+
// }
208+
//],
209+
"max-params": 0, // limits the number of parameters that can be used in the function declaration.
210+
"max-statements": 0, // specify the maximum number of statement allowed in a function
211+
"no-bitwise": 0, // disallow use of bitwise operators
212+
"no-plusplus": 0 // disallow use of unary operators, ++ and --
213+
214+
}
215+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
lib
12
node_modules
23
coverage
34
dist
@@ -7,4 +8,6 @@ dist
78
!.gitignore
89
!.npmignore
910
!.babelrc
11+
!.eslintrc
12+
!.eslintignore
1013
!.travis.yml

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
},
2727
"devDependencies": {
2828
"chai": "^3.5.0",
29+
"eslint": "^2.12.0",
30+
"eslint-plugin-babel": "^3.2.0",
31+
"eslint-plugin-flow-vars": "^0.4.0",
32+
"eslint-plugin-react": "^5.1.1",
2933
"jsdom": "^8.1.0",
3034
"pragmatist": "^3.0.21",
3135
"react": "^15.1.0",

tests/.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"env": {
3+
"mocha": true
4+
}
5+
}

0 commit comments

Comments
 (0)