Skip to content

Commit f0e5a77

Browse files
committed
Initial commit.
0 parents  commit f0e5a77

18 files changed

+656
-0
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = tab
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.yml]
15+
indent_style = space
16+
indent_size = 4

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Change Log
2+
3+
## 2.4.0
4+
- Initial release

LICENSE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016 SmartThings, Inc.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# eslint-config-smartthings
2+
SmartThing's ESLint config, following our style guide.
3+
Based on [Airbnb's Javascript styleguide](https://github.com/airbnb/javascript)
4+
5+
### eslint-config-smartthings
6+
7+
Lints ES6+ but does not lint React. Requires `eslint` and `babel-eslint`.
8+
9+
- Add `"extends": "smartthings"` to your .eslintrc
10+
11+
### eslint-config-smartthings/react
12+
13+
Contains all of our ESLint rules, including EcmaScript 6+
14+
and React. It requires `eslint`, `babel-eslint`, and `eslint-plugin-react`.
15+
16+
- Add `"extends": "smartthings/react"` to your .eslintrc
17+
18+
### eslint-config-smartthings/legacy
19+
20+
Lints ES5 and below. Only requires `eslint`.
21+
22+
- Add `"extends": "smartthings/legacy"` to your .eslintrc
23+
24+
## Resources
25+
- https://github.com/eslint/eslint
26+
- https://github.com/babel/babel-eslint
27+
- https://github.com/yannickcr/eslint-plugin-react

index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
'extends': [
3+
'eslint-config-smartthings/legacy',
4+
'eslint-config-smartthings/rules/es6'
5+
],
6+
'parser': 'babel-eslint',
7+
'rules': {}
8+
};

legacy.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
'extends': [
3+
'eslint-config-smartthings/rules/best-practices',
4+
'eslint-config-smartthings/rules/errors',
5+
'eslint-config-smartthings/rules/legacy',
6+
'eslint-config-smartthings/rules/node',
7+
'eslint-config-smartthings/rules/strict',
8+
'eslint-config-smartthings/rules/style',
9+
'eslint-config-smartthings/rules/variables'
10+
],
11+
'env': {
12+
'browser': true,
13+
'node': true,
14+
'amd': false,
15+
'mocha': false,
16+
'jasmine': false
17+
},
18+
'ecmaFeatures': {},
19+
'globals': {},
20+
'rules': {}
21+
};

package.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "eslint-config-smartthings",
3+
"version": "2.4.0",
4+
"description": "SmartThings's ESLint config",
5+
"main": "index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/SmartThingsOSS/eslint-config-smartthings"
9+
},
10+
"keywords": [
11+
"eslint",
12+
"eslintconfig",
13+
"config",
14+
"smartthings",
15+
"javascript",
16+
"styleguide"
17+
],
18+
"author": {
19+
"name": "SmartThings",
20+
"url": "http://www.smartthings.com"
21+
},
22+
"contributors": [
23+
{
24+
"name": "Adan Perez @adanperez",
25+
"url": "http://github.com/adanperez"
26+
}
27+
],
28+
"license": "Apache-2.0",
29+
"bugs": {
30+
"url": "https://github.com/SmartThingsOSS/eslint-config-smartthings/issues"
31+
},
32+
"homepage": "https://github.com/SmartThingsOSS/eslint-config-smartthings",
33+
"peerDependencies": {
34+
"eslint": "^2.x",
35+
"eslint-plugin-react": "^4.x"
36+
}
37+
}

react.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
'extends': [
3+
'eslint-config-smartthings/index',
4+
'eslint-config-smartthings/rules/react'
5+
],
6+
rules: {}
7+
};

rules/best-practices.js

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
module.exports = {
2+
'rules': {
3+
// Enforces getter/setter pairs in objects
4+
'accessor-pairs': 0,
5+
// treat var statements as if they were block scoped
6+
'block-scoped-var': 2,
7+
// specify the maximum cyclomatic complexity allowed in a program
8+
'complexity': [0, 11],
9+
// require return statements to either always or never specify values
10+
'consistent-return': 2,
11+
// specify curly brace conventions for all control statements
12+
'curly': [2, 'multi-line'],
13+
// require default case in switch statements
14+
'default-case': 2,
15+
// encourages use of dot notation whenever possible
16+
'dot-notation': [2, { 'allowKeywords': true }],
17+
// enforces consistent newlines before or after dots
18+
'dot-location': 0,
19+
// require the use of === and !==
20+
'eqeqeq': 2,
21+
// make sure for-in loops have an if statement
22+
'guard-for-in': 2,
23+
// disallow the use of alert, confirm, and prompt
24+
'no-alert': 1,
25+
// disallow use of arguments.caller or arguments.callee
26+
'no-caller': 2,
27+
// disallow lexical declarations in case clauses
28+
'no-case-declarations': 2,
29+
// disallow division operators explicitly at beginning of regular expression
30+
'no-div-regex': 0,
31+
// disallow else after a return in an if
32+
'no-else-return': 2,
33+
// disallow empty destructuring patterns
34+
'no-empty-pattern': 2,
35+
// disallow comparisons to null without a type-checking operator
36+
'no-eq-null': 0,
37+
// disallow use of eval()
38+
'no-eval': 2,
39+
// disallow adding to native types
40+
'no-extend-native': 2,
41+
// disallow unnecessary function binding
42+
'no-extra-bind': 2,
43+
// disallow fallthrough of case statements
44+
'no-fallthrough': 2,
45+
// disallow the use of leading or trailing decimal points in numeric literals
46+
'no-floating-decimal': 2,
47+
// disallow the type conversions with shorter notations
48+
'no-implicit-coercion': 0,
49+
// disallow use of eval()-like methods
50+
'no-implied-eval': 2,
51+
// disallow this keywords outside of classes or class-like objects
52+
'no-invalid-this': 0,
53+
// disallow usage of __iterator__ property
54+
'no-iterator': 2,
55+
// disallow use of labeled statements
56+
'no-labels': 2,
57+
// disallow unnecessary nested blocks
58+
'no-lone-blocks': 2,
59+
// disallow creation of functions within loops
60+
'no-loop-func': 2,
61+
// disallow use of multiple spaces
62+
'no-multi-spaces': 2,
63+
// disallow use of multiline strings
64+
'no-multi-str': 2,
65+
// disallow reassignments of native objects
66+
'no-native-reassign': 2,
67+
// disallow use of new operator when not part of the assignment or comparison
68+
'no-new': 2,
69+
// disallow use of new operator for Function object
70+
'no-new-func': 2,
71+
// disallows creating new instances of String,Number, and Boolean
72+
'no-new-wrappers': 2,
73+
// disallow use of (old style) octal literals
74+
'no-octal': 2,
75+
// disallow use of octal escape sequences in string literals, such as
76+
// var foo = 'Copyright \251';
77+
'no-octal-escape': 2,
78+
// disallow reassignment of function parameters
79+
'no-param-reassign': 2,
80+
// disallow use of process.env
81+
'no-process-env': 0,
82+
// disallow usage of __proto__ property
83+
'no-proto': 2,
84+
// disallow declaring the same variable more then once
85+
'no-redeclare': 2,
86+
// disallow use of assignment in return statement
87+
'no-return-assign': 2,
88+
// disallow use of `javascript:` urls.
89+
'no-script-url': 2,
90+
// disallow assignments where both sides are exactly the same
91+
'no-self-assign': 2,
92+
// disallow comparisons where both sides are exactly the same
93+
'no-self-compare': 2,
94+
// disallow use of comma operator
95+
'no-sequences': 2,
96+
// restrict what can be thrown as an exception
97+
'no-throw-literal': 2,
98+
// disallow usage of expressions in statement position
99+
'no-unused-expressions': 2,
100+
// disallow unused labels
101+
'no-unused-labels': 2,
102+
// disallow unnecessary .call() and .apply()
103+
'no-useless-call': 0,
104+
// disallow use of void operator
105+
'no-void': 0,
106+
// disallow usage of configurable warning terms in comments: e.g. todo
107+
'no-warning-comments': [0, { 'terms': ['todo', 'fixme', 'xxx'], 'location': 'start' }],
108+
// disallow use of the with statement
109+
'no-with': 2,
110+
// require use of the second argument for parseInt()
111+
'radix': 2,
112+
// requires to declare all vars on top of their containing scope
113+
'vars-on-top': 2,
114+
// require immediate function invocation to be wrapped in parentheses
115+
'wrap-iife': [2, 'any'],
116+
// require or disallow Yoda conditions
117+
'yoda': 2
118+
}
119+
};

rules/errors.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
module.exports = {
2+
'rules': {
3+
// disallow trailing commas in object literals
4+
'comma-dangle': [2, 'never'],
5+
// disallow assignment in conditional expressions
6+
'no-cond-assign': [2, 'always'],
7+
// disallow use of console
8+
'no-console': 1,
9+
// disallow use of constant expressions in conditions
10+
'no-constant-condition': 2,
11+
// disallow control characters in regular expressions
12+
'no-control-regex': 2,
13+
// disallow use of debugger
14+
'no-debugger': 1,
15+
// disallow duplicate arguments in functions
16+
'no-dupe-args': 2,
17+
// disallow duplicate keys when creating object literals
18+
'no-dupe-keys': 2,
19+
// disallow a duplicate case label.
20+
'no-duplicate-case': 2,
21+
// disallow the use of empty character classes in regular expressions
22+
'no-empty-character-class': 2,
23+
// disallow empty statements
24+
'no-empty': 2,
25+
// disallow assigning to the exception in a catch block
26+
'no-ex-assign': 2,
27+
// disallow double-negation boolean casts in a boolean context
28+
'no-extra-boolean-cast': 0,
29+
// disallow unnecessary parentheses
30+
'no-extra-parens': [2, 'functions'],
31+
// disallow unnecessary semicolons
32+
'no-extra-semi': 2,
33+
// disallow overwriting functions written as function declarations
34+
'no-func-assign': 2,
35+
// disallow function or variable declarations in nested blocks
36+
'no-inner-declarations': 2,
37+
// disallow invalid regular expression strings in the RegExp constructor
38+
'no-invalid-regexp': 2,
39+
// disallow irregular whitespace outside of strings and comments
40+
'no-irregular-whitespace': 2,
41+
// disallow negation of the left operand of an in expression
42+
'no-negated-in-lhs': 2,
43+
// disallow the use of object properties of the global object (Math and JSON) as functions
44+
'no-obj-calls': 2,
45+
// disallow multiple spaces in a regular expression literal
46+
'no-regex-spaces': 2,
47+
// disallow sparse arrays
48+
'no-sparse-arrays': 2,
49+
// disallow unreachable statements after a return, throw, continue, or break statement
50+
'no-unreachable': 2,
51+
// disallow comparisons with the value NaN
52+
'use-isnan': 2,
53+
// ensure JSDoc comments are valid
54+
'valid-jsdoc': 0,
55+
// ensure that the results of typeof are compared against a valid string
56+
'valid-typeof': 2,
57+
// Avoid code that looks like two expressions but is actually one
58+
'no-unexpected-multiline': 1
59+
}
60+
};

rules/es6.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module.exports = {
2+
'env': {
3+
'es6': true
4+
},
5+
'parserOptions': {
6+
'ecmaVersion': 6
7+
},
8+
'rules': {
9+
// require parens in arrow function arguments
10+
'arrow-parens': 0,
11+
// require space before/after arrow function's arrow
12+
'arrow-spacing': 0,
13+
// verify super() callings in constructors
14+
'constructor-super': 2,
15+
// enforce the spacing around the * in generator functions
16+
'generator-star-spacing': 0,
17+
// disallow modifying variables of class declarations
18+
'no-class-assign': 2,
19+
// disallow arrow functions where they could be confused with comparisons
20+
'no-confusing-arrow': 2,
21+
// disallow modifying variables that are declared using const
22+
'no-const-assign': 2,
23+
// disallow duplicate name in class members
24+
'no-dupe-class-members': 2,
25+
// disallow Symbol Constructor
26+
'no-new-symbol': 2,
27+
// disallow to use this/super before super() calling in constructors.
28+
'no-this-before-super': 2,
29+
// require let or const instead of var
30+
'no-var': 2,
31+
// require method and property shorthand syntax for object literals
32+
'object-shorthand': 0,
33+
// suggest using of const declaration for variables that are never modified after declared
34+
'prefer-const': 2,
35+
// suggest using the spread operator instead of .apply()
36+
'prefer-spread': 0,
37+
// suggest using Reflect methods where applicable
38+
'prefer-reflect': 0,
39+
// disallow generator functions that do not have yield
40+
'require-yield': 0
41+
}
42+
};

rules/legacy.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
'rules': {
3+
// specify the maximum depth that blocks can be nested
4+
'max-depth': [0, 4],
5+
// specify the maximum length of a line in your program
6+
'max-len': [0, 80, 4],
7+
// limits the number of parameters that can be used in the function declaration.
8+
'max-params': [0, 3],
9+
// specify the maximum number of statement allowed in a function
10+
'max-statements': [0, 10],
11+
// disallow use of bitwise operators
12+
'no-bitwise': 0,
13+
// disallow use of unary operators, ++ and --
14+
'no-plusplus': 0
15+
}
16+
};

0 commit comments

Comments
 (0)