Skip to content

Commit

Permalink
feat: simplify configs (#124)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: ES6, import & main configs don't have sub-configs anymore
  • Loading branch information
MichaelDeBoey authored Jan 7, 2022
1 parent 299cc53 commit 1135764
Show file tree
Hide file tree
Showing 23 changed files with 556 additions and 743 deletions.
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,14 @@ for it.
- All plugins needed for rules used by these configs are dependencies of this
module so you don't have to install anything on your own.
- The default config actually is composed of several configurations and you can
use those individually. These are the configs it's using:
`possible-errors.js`, `best-practices.js`, `stylistic.js`, `es6/index.js`, and
`import/index.js`. You can use each of these configs yourself if you want to
leave my own personal style out of it. Also, the `es6` and `import` configs
each have a `possible-errors.js`, `best-practices.js`, and `stylistic.js`
which they are composed of as well.
use those individually. You can use each of these configs yourself if you want
to leave my own personal style out of it.

#### Example of highly customized config
#### Example of customized config

```javascript
module.exports = {
extends: [
'kentcdodds/possible-errors',
'kentcdodds/best-practices',
'kentcdodds/es6/possible-errors',
'kentcdodds/import',
'kentcdodds/jest',
],
extends: ['kentcdodds/es6', 'kentcdodds/import', 'kentcdodds/jest'],
rules: {
/* custom rules */
},
Expand Down
218 changes: 0 additions & 218 deletions best-practices.js

This file was deleted.

30 changes: 0 additions & 30 deletions deprecated-rules.js

This file was deleted.

92 changes: 92 additions & 0 deletions es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
module.exports = {
env: {
es6: true,
},
extends: ['prettier'],
parser: '@babel/eslint-parser',
parserOptions: {
babelOptions: {
presets: ['@babel/preset-react'],
},
ecmaVersion: 2018,
requireConfigFile: false,
sourceType: 'module',
},
plugins: ['@babel'],
rules: {
'arrow-body-style': 'off',
'constructor-super': 'error',
'no-class-assign': 'error',
'no-const-assign': 'error',
'no-dupe-class-members': 'error',
'no-duplicate-imports': 'error',
'no-new-symbol': 'error',
'no-restricted-exports': 'off', // not applicable for a config preset (should be configured only in projects)
'no-restricted-imports': 'off', // not applicable for a config preset (should be configured only in projects)
'no-this-before-super': 'error',
'no-unsafe-optional-chaining': 'error',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': 'error',
'no-var': 'error',
'object-shorthand': ['error', 'properties'], // methods are optional so you can specify a name if you want
'prefer-arrow-callback': [
'error',
{allowNamedFunctions: true, allowUnboundThis: true},
],
'prefer-const': 'error',
'prefer-destructuring': 'off', // nah, I like it, but not that much...
'prefer-numeric-literals': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'require-yield': 'error',
'sort-imports': 'off',
'symbol-description': 'error',

'new-cap': 'off',
'@babel/new-cap': ['error', {capIsNew: true, newIsCap: true}],

'no-invalid-this': 'off',
'@babel/no-invalid-this': 'error',

'no-unused-expressions': 'off',
'@babel/no-unused-expressions': 'error',
},
overrides: [
{
files: ['**/*.ts?(x)'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
rules: {
'constructor-super': 'off', // ts(2335) & ts(2377)
'no-const-assign': 'off', // ts(2588)
'no-new-symbol': 'off', // ts(2588)
'no-this-before-super': 'off', // ts(2376)
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
'prefer-const': 'error', // ts provides better types with const
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply

'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': 'off', // ts(2393) & ts(2300)

'no-duplicate-imports': 'off',
'@typescript-eslint/no-duplicate-imports': 'error',

'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',

'@babel/no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': 'error',

'@babel/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'error',
},
},
],
}
Loading

0 comments on commit 1135764

Please sign in to comment.