eslint-config-soda
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -5,4 +5,2 @@ module.exports = { | ||
'eslint-config-soda/rules/react', | ||
'eslint-config-soda/rules/best-practices', | ||
@@ -9,0 +7,0 @@ 'eslint-config-soda/rules/complexity', |
The MIT License (MIT) | ||
Copyright (c) 2015 Haoqun Jiang | ||
Copyright (c) 2016 Haoqun Jiang | ||
@@ -22,2 +22,1 @@ Permission is hereby granted, free of charge, to any person obtaining a copy | ||
SOFTWARE. | ||
{ | ||
"name": "eslint-config-soda", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "ESLint configurations for my personal projects", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "eslint ." | ||
}, | ||
"repository": { | ||
@@ -20,11 +17,7 @@ "type": "git", | ||
"dependencies": { | ||
"babel-eslint": "^6.0.0-beta.6", | ||
"eslint": "^2.4.0", | ||
"eslint-plugin-react": "^4.2.3" | ||
"eslint": "^2.8.0" | ||
}, | ||
"peerDependencies": { | ||
"babel-eslint": "^6.0.0-beta.6", | ||
"eslint": "^2.4.0", | ||
"eslint-plugin-react": "^4.2.3" | ||
"eslint": "^2.8.0" | ||
} | ||
} |
# eslint-config-soda | ||
ESLint configurations for my personal projects. | ||
Largely influenced by [eslint-config-airbnb](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb) | ||
but with my personal understanding. | ||
## TODO | ||
1. `babel-eslint` still has issues on ESLint v2, keep an eye on its development. | ||
2. Since ESLint v2 removes the `ecmaFeatures` that are specific to ES6, | ||
Since ESLint v2 removes the `ecmaFeatures` that are specific to ES6, | ||
we now need to develop a plugin to disable some unrecommended ES6 features. | ||
@@ -26,8 +22,7 @@ This features are: | ||
The default export contains all of our ESLint rules, including ES6+ and React. | ||
It requires `eslint`, `babel-eslint`, and `eslint-plugin-react`. | ||
The default export contains all of our ESLint rules, including ES6+ features while compatible with ES3+ environments. | ||
It is a general-purpose rule set, so many redundant rules are enabled, and conflict rules are disabled. | ||
1. `npm install --save-dev eslint-config-soda babel-eslint eslint-plugin-react eslint` | ||
1. `npm install --save-dev eslint eslint-config-soda` | ||
2. add `"extends": "soda"` to your `.eslintrc` | ||
@@ -37,5 +32,5 @@ | ||
Lints Node.js projects. Requires `eslint` and `babel-eslint`. | ||
Lints Node.js projects, including rules for ES6+ features. | ||
1. `npm install --save-dev eslint-config-soda babel-eslint eslint` | ||
1. `npm install --save-dev eslint eslint-config-soda` | ||
2. add `"extends": "soda/node"` to your `.eslintrc` | ||
@@ -45,7 +40,6 @@ | ||
Lints front end projects, including rules for ES6+ and React | ||
Lints front-end projects, including rules for ES6+ features. | ||
(generators/async/await are disabled since transpiling these features will introduce a lot of overhead). | ||
It requires `eslint` and `babel-eslint`. | ||
1. `npm install --save-dev eslint-config-soda babel-eslint eslint` | ||
1. `npm install --save-dev eslint eslint-config-soda` | ||
2. add `"extends": "soda/browser"` to your `.eslintrc` | ||
@@ -55,3 +49,3 @@ | ||
Lints ES5 and below, for browser use only. Only requires `eslint`. | ||
Lints ES5 and below, for browser use only. | ||
@@ -61,8 +55,2 @@ 1. `npm install --save-dev eslint-config-soda eslint` | ||
### eslint-config-soda/react | ||
Opt-in. Only includes react-related rules. | ||
If you are developing a React.js project, you might want to extend this ruleset, | ||
along with any other previously mentioned ruleset. | ||
### Module Loader | ||
@@ -104,1 +92,5 @@ | ||
``` | ||
### React Projects | ||
If you are developing a React.js project, you might need the ruleset `eslint-config-soda-react`. |
@@ -12,5 +12,8 @@ // Possible Errors & Best Practices | ||
// Warns when using methods in `console` object | ||
// Since `console` is usually used for debugging purpose, Thus should not be used in production environments | ||
// Since `console` is usually used for debugging purpose, thus should not be used in production environments | ||
'no-console': 'warn', | ||
// Production code should definitely not contain `debugger` | ||
// Also, with the advent of modern debugging and development tools, | ||
// `debugger` statement is less and less useful even in development environments. | ||
// 一般情况下不应该使用 debugger 语句进行调试 | ||
@@ -47,3 +50,4 @@ 'no-debugger': 'error', | ||
// 空代码块应该警告 | ||
// Empty block statements, while not technically errors, usually occur due to refactoring that wasn't completed | ||
// 出现空代码块一般是因为重构不完整,很有可能是忘了实现什么功能,所以除非明确注释说有意留空,不然都要警告 | ||
'no-empty': 'warn', | ||
@@ -294,2 +298,5 @@ | ||
// 在字符串或者正则表达式里使用无效的转义字符是没有效果的,因此这很有可能是写错了 | ||
'no-useless-escape': 'error', | ||
// ES5- 的 undefined 是可覆盖赋值的,而且子作用域里可以定义一个叫 undefined 的变量覆盖掉全局的 undefined | ||
@@ -296,0 +303,0 @@ // 所以此时需要用 void 0 获得真正的 undefined |
@@ -5,3 +5,3 @@ /* eslint-disable no-magic-numbers */ | ||
// 单个函数最多有 50 行(内部的其他函数定义不算) | ||
'max-statements': ['warn', 50], | ||
'max-statements': ['warn', { max: 50 }], | ||
@@ -15,10 +15,10 @@ // 每行最多 140 个字符,比 80 个字符多一点,毕竟可能会有很多缩进,而且反正显示器够大 | ||
// 对于 AMD 格式以及 Angular 1.x 模块,最好通过 inline comments 的方式关闭这条规则 | ||
'max-params': ['warn', 5], | ||
'max-params': ['warn', { max: 5 }], | ||
// 至多嵌套五层代码块 | ||
'max-depth': ['warn', 5], | ||
// 至多嵌套 5 层代码块 | ||
'max-depth': ['warn', { max: 5 }], | ||
// Too many nested callbacks would be hard to read | ||
// 最多允许嵌套两层回调 | ||
'max-nested-callbacks': ['warn', 4], | ||
// 最多允许嵌套 4 层回调 | ||
'max-nested-callbacks': ['warn', { max: 4 }], | ||
@@ -29,4 +29,4 @@ // [cyclomatic complexity](http://en.wikipedia.org/wiki/Cyclomatic_complexity) should be no greater than 15 | ||
// 圈复杂度上限为 15 | ||
'complexity': ['warn', 8] | ||
'complexity': ['warn', { max: 8 }] | ||
} | ||
} |
module.exports = { | ||
// temporarily disable babel-eslint, for eslint v2.3.0 compatibility | ||
parser: 'babel-eslint', | ||
env: { | ||
es6: true | ||
es6: true // enable ES6+ globals such as Promise, Symbol, etc. | ||
}, | ||
@@ -84,3 +82,5 @@ parserOptions: { | ||
// 对于不会被修改的变量,优先考虑使用 const 而非 let | ||
'prefer-const': 'warn', | ||
// Besides, if all variables in destructuring should be `const`, this rule warns the variables; | ||
// otherwise, ignores them. | ||
'prefer-const': ['warn', { destructuring: 'all' }], | ||
@@ -93,4 +93,7 @@ // 如果仅仅是为了使用数组作为函数参数,那么应该优先考虑使用 spread operator 而不是 .apply() | ||
// 回调函数尽可能使用箭头函数,而不是 Inline 的匿名函数 | ||
'prefer-arrow-callback': 'warn', | ||
// It's better to use arrow functions as callbacks, | ||
// unless you need to have a special `this` binding for the callback, | ||
// or you want the function be named. | ||
// 回调函数尽可能使用箭头函数,而不是 inline 的匿名函数 | ||
'prefer-arrow-callback': ['warn', { allowNamedFunctions: true }], | ||
@@ -112,4 +115,6 @@ // 禁止复杂的字符串拼接,用模板引擎或 ES6 template string 替代 | ||
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'] | ||
}] | ||
}], | ||
'no-duplicate-imports': ['warn', { includeExports: false }] | ||
} | ||
} |
@@ -1,5 +0,5 @@ | ||
// for ES5- environments | ||
// For ES5- environments | ||
module.exports = { | ||
rules: { | ||
// disable es6 rules that conflict with legacy environments | ||
// Disable es6 rules that conflict with legacy environments | ||
'no-var': 'off', | ||
@@ -6,0 +6,0 @@ 'prefer-const': 'off', |
@@ -37,3 +37,4 @@ module.exports = { | ||
// 一律使用单引号,除非字符串的值中有单引号 | ||
'quotes': ['warn', 'single', 'avoid-escape'], | ||
// 只在必要时(用到了变量替换、换行或者 tagged templates 这几个特性之一)使用 template literals | ||
'quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: false }], | ||
@@ -44,3 +45,3 @@ // 采用 4 个空格缩进,可以使代码看起来更整洁点 | ||
// 严禁空格和 Tab 混用 | ||
'no-mixed-spaces-and-tabs': 2, | ||
'no-mixed-spaces-and-tabs': 'error', | ||
@@ -196,4 +197,7 @@ // 禁止多个连续空格 | ||
// in variable declarations, function declarations and object properties | ||
'id-blacklist': 'off' | ||
'id-blacklist': 'off', | ||
// A line of code containing too many statements can be difficult to read | ||
'max-statements-per-line': ['warn', { max: 3 }] | ||
} | ||
} |
@@ -45,3 +45,3 @@ module.exports = { | ||
// 定义过的变量都要被用到,不然的话很可能是没重构完导致的错误 | ||
'no-unused-vars': ['warn', { vars: 'all', args: 'after-used' }], | ||
'no-unused-vars': ['warn', { vars: 'all', args: 'after-used', caughtErrors: 'none' }], | ||
@@ -48,0 +48,0 @@ // Magic numbers should preferably be replaced by named constants |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
44815
18
641
91
- Removedbabel-eslint@^6.0.0-beta.6
- Removedeslint-plugin-react@^4.2.3
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbabel-eslint@6.1.2(transitive)
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-traverse@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedeslint-plugin-react@4.3.0(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedlodash.assign@4.2.0(transitive)
- Removedlodash.pickby@4.6.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedto-fast-properties@1.0.3(transitive)
Updatedeslint@^2.8.0