Skip to content

Commit

Permalink
feat: clear airbnb rules, use eslint:recommended instead (#9)
Browse files Browse the repository at this point in the history
* feat: add use strict

* WIP: use eslint:recommended

* WIP: clear rules

* feat: add jest eslint config

* WIP: update
  • Loading branch information
leohxj authored Aug 12, 2019
1 parent 527c33b commit b2572e0
Show file tree
Hide file tree
Showing 24 changed files with 187 additions and 1,837 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"scripts": {
"changelog": "lerna-changelog",
"publish": "lerna publish",
"lint": "eslint . --ext js",
"lint": "eslint --ext .js ./",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand Down
7 changes: 7 additions & 0 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,10 @@
}
```

### jest 环境
`npm i -D @mjolnir/eslint-config eslint eslint-plugin-jest`

#### 配置
```json

```
8 changes: 4 additions & 4 deletions packages/eslint-config/babel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

// for babel env, base on es6 env
module.exports = {
extends: [
'./index', // 基于 es6 的配置
'./plugins/babel'
].map(require.resolve)
extends: ['./index', './plugins/babel'].map(require.resolve)
};
17 changes: 11 additions & 6 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
'use strict';

// for es6 env
module.exports = {
root: true, // limit ESLint to a specific project
env: {
browser: true,
es6: true // also enable ecmaVersion: 6
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaVersion: 2018, // same as 9
sourceType: 'module', // ECMAScript module
ecmaFeatures: {
globalReturn: false,
impliedStrict: true,
jsx: true
}
},
env: {
browser: true,
es6: true
},
extends: ['./rules', './plugins/import'].map(require.resolve)
};
7 changes: 7 additions & 0 deletions packages/eslint-config/jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

// for jest env
module.exports = {
extends: ['./index', './plugins/jest'].map(require.resolve),
rules: {}
};
6 changes: 5 additions & 1 deletion packages/eslint-config/node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
'use strict';

// for nodejs env, support es6+ syntax
module.exports = {
extends: ['./rules', './plugins/node'].map(require.resolve)
root: true, // limit ESLint to a specific project
extends: ['./rules', './plugins/node'].map(require.resolve),
rules: {}
};
7 changes: 5 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "https://github.com/mjolnirjs/mjolnir/issues"
},
"scripts": {
"test": "prettier --version"
"lint": "eslint --print-config ./index.js"
},
"keywords": [
"eslint",
Expand All @@ -22,9 +22,12 @@
],
"license": "MIT",
"peerDependencies": {
"eslint": "^5.16.0 || ^6.0.0"
"eslint": "^6.0.0"
},
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=8.0.0"
}
}
2 changes: 2 additions & 0 deletions packages/eslint-config/plugins/babel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

// eslint-plugin-babel has no recommend config
module.exports = {
parser: 'babel-eslint',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config/plugins/import.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = {
plugins: ['import'],
rules: {
Expand Down
7 changes: 7 additions & 0 deletions packages/eslint-config/plugins/jest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

// plugin:jest/recommended: https://github.com/jest-community/eslint-plugin-jest/blob/master/README.md
module.exports = {
extends: ['plugin:jest/recommended'],
rules: {}
};
40 changes: 5 additions & 35 deletions packages/eslint-config/plugins/node.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,10 @@
'use strict';

// plugin:node/recommended: https://github.com/mysticatea/eslint-plugin-node/blob/master/lib/index.js
module.exports = {
extends: ['plugin:node/recommended'],
rules: {
// enforce return after a callback
'callback-return': 'off',

// require all requires be top-level
// https://eslint.org/docs/rules/global-require
'global-require': 'error',

// enforces error handling in callbacks (node environment)
'handle-callback-err': 'off',

// disallow use of the Buffer() constructor
// https://eslint.org/docs/rules/no-buffer-constructor
'no-buffer-constructor': 'error',

// disallow mixing regular variable and require declarations
'no-mixed-requires': ['off', false],

// disallow use of new operator with the require function
'no-new-require': 'error',

// disallow string concatenation with __dirname and __filename
// https://eslint.org/docs/rules/no-path-concat
'no-path-concat': 'error',

// disallow use of process.env
'no-process-env': 'off',

// disallow process.exit()
'no-process-exit': 'off',

// restrict usage of specified node modules
'no-restricted-modules': 'off',

// disallow use of synchronous methods (off by default)
'no-sync': 'off'
// commonjs or node env, should use global strict model
strict: ['error', 'global']
}
};
2 changes: 2 additions & 0 deletions packages/eslint-config/plugins/react-hooks.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

module.exports = {
plugins: ['react-hooks'],
rules: {
Expand Down
Loading

0 comments on commit b2572e0

Please # to comment.