Skip to content

Commit

Permalink
feat(configs): Upgrade ESLint and update all rules
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Upgrade ESLint and update rules.
BREAKING CHANGE: Remove test-angular
BREAKING CHANGE: Remove es-next
BREAKING CHANGE: Rename test to mocha
BREAKING CHANGE: webpack now extends index
  • Loading branch information
Kent C. Dodds committed Jul 7, 2016
1 parent 0db3bd1 commit 8cb2c77
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 86 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"rules": {
"quotes": [2, "double"], // because I may want to move this config to an .eslintrc eventually...
"quote-props": 0, // same reason...
"no-magic-numbers": 0, // because rules are 0, 1, 2
}
}
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ branches:
only:
- master
node_js:
- iojs
before_install:
- npm i -g npm@^2.0.0
- 6
before_script:
- npm prune
script:
Expand Down
38 changes: 10 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
[![MIT License](https://img.shields.io/npm/l/eslint-config-kentcdodds.svg?style=flat-square)](http://opensource.org/licenses/MIT)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)


ESLint rules for all of my personal projects. Feel free to use these conventions :-)


## Usage

Install the conventions by running:
Expand All @@ -29,60 +27,44 @@ Then add the extends to your `.eslintrc`:
}
```

### Test and test-angular
### Mocha

This config lib also includes a `test` and a `test-angular` config:

**Note if you use these, you need to install `eslint-plugin-mocha`**
This config lib also includes a [`mocha`](https://mochajs.org/) config

```javascript
{
"extends": "kentcdodds/test"
"extends": "kentcdodds/mocha"
}
```

### AVA

This config lib also includes an [`AVA`](https://github.com/avajs/ava) config

```javascript
{
"extends": "kentcdodds/test-angular"
"extends": "kentcdodds/ava"
}
```

### React

This config lib also includes a `react` config:

**Note if you use this, you'll also need to install `eslint-plugin-react`**:

This extends `es-next` which has requirements as well

```javascript
{
"extends": "kentcdodds/react"
}
```

### es-next

If you want to use ES.next goodness, you can reference the `es-next` config:

**Note if you use this, you'll also need to install `babel-eslint`**:

```javascript
{
"extends": "kentcdodds/es-next"
}
```

### webpack
### Webpack

We lint your import/require statements. With webpack overloading these, you may
want to have these resolved the way webpack resolves them for you.

**Note if you use this, you'll also need to install `eslint-import-resolver-webpack`**:

```javascript
{
"extends": ["kentcdodds", "kentcdodds/webpack"]
"extends": "kentcdodds/webpack"
}
```

Expand Down
26 changes: 26 additions & 0 deletions ava.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
"extends": "./index.js",
"plugins": ["ava"],
"rules": {
"ava/assertion-arguments": 2,
"ava/assertion-message": 0,
"ava/max-asserts": 0,
"ava/no-cb-test": 0,
"ava/no-identical-title": 2,
"ava/no-ignored-test-files": 2,
"ava/no-invalid-end": 2,
"ava/no-only-test": 2,
"ava/no-skip-assert": 1,
"ava/no-skip-test": 2,
"ava/no-statement-after-end": 2,
"ava/no-todo-test": 0,
"ava/no-unknown-modifiers": 2,
"ava/prefer-power-assert": 0, // not sure this rule is correct
"ava/test-ended": 2,
"ava/test-title": 2,
"ava/use-t-well": 2,
"ava/use-t": 2,
"ava/use-test": 2,
"ava/use-true-false": 2,
},
}
4 changes: 0 additions & 4 deletions es-next.js

This file was deleted.

14 changes: 0 additions & 14 deletions import.js

This file was deleted.

99 changes: 91 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,36 @@ module.exports = {
"spaced-line-comment": 0,

// possible errors
"array-callback-return": 2,
"arrow-body-style": [2, "as-needed"],
"arrow-parens": [2, "as-needed"],
"arrow-spacing": [2, {"before": true, "after": true}],
"block-scoped-var": 2,
"block-spacing": 2,
"callback-return": 2,
"global-require": 2,
"handle-callback-err": 2,
"init-declarations": 0,
"space-infix-ops": 2,
"no-cond-assign": 2,
"no-confusing-arrow": [2, {"allowParens": true}],
"no-console": 2,
"no-const-assign": 2,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-process-env": 0,
"no-empty-function": 2,
"no-debugger": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-duplicate-imports": 2,
"no-empty": 2,
"no-empty-character-class": 2,
"no-empty-pattern": 2,
"no-ex-assign": 2,
"no-extra-boolean-cast": 0,
"no-extra-label": 2,
"no-extra-parens": 0,
"no-extra-semi": 2,
"no-func-assign": 2,
Expand All @@ -43,11 +59,19 @@ module.exports = {
"no-irregular-whitespace": 2,
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-process-env": 0,
"no-regex-spaces": 2,
"no-reserved-keys": 0,
"no-self-assign": 2,
"no-sparse-arrays": 2,
"no-unreachable": 2,
"no-unexpected-multiline": 2,
"no-unmodified-loop-condition": 2,
"no-unreachable": 2,
"no-unsafe-finally": 2,
"no-unused-labels": 2,
"no-useless-call": 2,
"require-yield": 2,
"unicode-bom": [2, "never"],
"use-isnan": 2,
"valid-jsdoc": [2, {"requireReturn": false}],
"valid-typeof": 2,
Expand Down Expand Up @@ -76,10 +100,16 @@ module.exports = {
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-implied-eval": 2,
"no-implicit-coercion": 0,
"no-implicit-globals": 2,
"no-invalid-this": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-magic-numbers": 2,
"no-mixed-operators": 0,
"no-mixed-requires": 0,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
Expand All @@ -89,15 +119,27 @@ module.exports = {
"no-octal-escape": 2,
"no-octal": 2,
"no-param-reassign": 0,
"no-path-concat": 2,
"no-process-exit": 2,
"no-proto": 2,
"no-prototype-builtins": 0,
"no-redeclare": 2,
"no-restricted-globals": 2,
"no-restricted-syntax": [2, "WithStatement"],
"no-return-assign": 2,
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-sync": 0,
"no-throw-literal": 2,
"no-useless-computed-key": 2,
"no-useless-concat": 2,
"no-useless-constructor": 2,
"no-useless-escape": 2,
"no-useless-rename": 2,
"no-void": 2,
"no-warning-comments": [2, {"terms": ["fixme"], "location": "anywhere"}],
"no-whitespace-before-property": 2,
"no-with": 0,
"radix": 2,
"vars-on-top": 2,
Expand All @@ -124,39 +166,65 @@ module.exports = {
"eol-last": 2,
"func-names": 2,
"func-style": [2, "declaration"],
"id-blacklist": 2,
"id-length": [2, {"properties": "never"}],
"id-match": [2, "^[a-z]+([A-Z][a-z]+)*$"], // matches camelCase
"jsx-quotes": [2, "prefer-double"],
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
"keyword-spacing": [2, {"before": true, "after": true}],
"lines-around-comment": 0,
"linebreak-style": [2, "unix"],
"max-lines": [2, {"max": 500, "skipBlankLines": false, "skipComments": false}],
"max-statements-per-line": [2, {"max": 1}],
"new-parens": 2,
"newline-after-var": 0,
"newline-before-return": 0,
"newline-per-chained-call": 0,
"no-array-constructor": 2,
"no-case-declarations": 2,
"no-class-assign": 2,
"no-continue": 2,
"no-inline-comments": 0,
"no-lonely-if": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multiple-empty-lines": 0,
"no-negated-condition": 2,
"no-nested-ternary": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-symbol": 2,
"no-spaced-func": 2,
"no-ternary": 0,
"no-trailing-spaces": [2, {"skipBlankLines": true}],
"no-underscore-dangle": 0,
"no-unneeded-ternary": 2,
"object-curly-spacing": [2, "never"],
"object-curly-newline": 0, // couldn't figure out how to configure it the way I want :-(
"object-property-newline": 0,
"one-var": [2, {"uninitialized": "always", "initialized": "never"}],
"one-var-declaration-per-line": 2,
"operator-assignment": 0, // readability on a case-by-case basis
"operator-linebreak": [2, "after"],
"padded-blocks": 0,
"prefer-arrow-callback": [2, {"allowNamedFunctions": true, "allowUnboundThis": true}],
"prefer-rest-params": 2,
"prefer-spread": 2,
"prefer-template": 2,
"quote-props": [2, "as-needed"],
"require-jsdoc": 0,
"rest-spread-spacing": [2, "never"],
"semi-spacing": [2, {"before": false, "after": true}],
"semi": [2, "never"],
"sort-vars": 0,
"sort-imports": 0,
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-unary-ops": [2, {"words": true, "nonwords": false}],
"spaced-comment": 0,
"template-curly-spacing": [2, "never"],
"wrap-regex": 0,
"yield-star-spacing": [2, {"before": false, "after": true}],
"constructor-super": 2,
"generator-star-spacing": [2, {"before": false, "after": true}],
"no-this-before-super": 2,
Expand All @@ -165,6 +233,11 @@ module.exports = {
"no-bitwise": 2,
"no-plusplus": 0,

// not applicable for a config preset (should be configured only in projects)
"no-restricted-imports": 0,
"no-restricted-modules": 0,
"prefer-reflect": 0, // maybe one day

"import/no-unresolved": 2,
"import/named": 2,
"import/default": 2,
Expand All @@ -173,6 +246,19 @@ module.exports = {
"import/no-named-as-default": 2,
"import/imports-first": 2,
"import/no-duplicates": 2,
"import/extensions": 2,
"import/newline-after-import": 2,
"import/no-amd": 2,
"import/no-commonjs": 0,
"import/no-deprecated": 1, // this is an in progress rule
"import/no-extraneous-dependencies": 2,
"import/no-mutable-exports": 2,
"import/no-named-as-default-member": 2,
"import/no-namespace": 0,
"import/no-nodejs-modules": 0,
"import/no-restricted-paths": 0,
"import/order": [1, {"groups": ["builtin", ["external", "internal"], "parent", ["sibling", "index"]]}],
"import/prefer-default-export": 1,
},
"env": {
"browser": true,
Expand All @@ -182,10 +268,7 @@ module.exports = {
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
},
},
"globals": {
"ecmaFeatures": {"experimentalObjectRestSpread": true},
},
"globals": {},
}
12 changes: 9 additions & 3 deletions test.js → mocha.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
module.exports = {
"extends": "kentcdodds",
"extends": "./index.js",
"plugins": [
"mocha",
],
"rules": {
"max-nested-callbacks": [2, 15], // them its and describes...
"max-len": [2, 240], // them verbose it statements
"mocha/no-exclusive-tests": 2, // never push exclusive tests

"mocha/handle-done-callback": 2, // don't forget that "done" !
"mocha/no-exclusive-tests": 2, // never push exclusive tests
"mocha/no-global-tests": 0,
"mocha/no-pending-tests": 0,
"mocha/no-skipped-tests": 0,
"mocha/no-synchronous-tests": 0,
"mocha/valid-suite-description": 0,
"mocha/valid-test-description": 0,
},
"env": {
"mocha": true,
Expand All @@ -18,4 +25,3 @@ module.exports = {
"sinon": false, // when using karma-sinon
},
}

Loading

0 comments on commit 8cb2c77

Please sign in to comment.