@polyv/eslint-config 0.6.0-beta.3 → 0.6.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,6 +13,8 @@ npm install @polyv/eslint-config --save-dev
13
13
  | 依赖 | 版本要求 | 纯 JS 工程 | 纯 TS 工程 | Vue.js 工程(JS) |
14
14
  | --- | --- | --- | --- | --- |
15
15
  | eslint | >=8.0.0 | √ | √ | √ |
16
+ | eslint-config-standard | >=17.0.0 | √ | √ | √ |
17
+ | eslint-plugin-n | >=15.7.0 | √ | √ | √ |
16
18
  | eslint-plugin-import | >= 2.0.0 | √ | √ | √ |
17
19
  | eslint-plugin-promise | >= 6.1.0 | √ | √ | √ |
18
20
  | eslint-plugin-sonarjs | >= 0.18.0 | √ | √ | √ |
@@ -21,6 +23,7 @@ npm install @polyv/eslint-config --save-dev
21
23
  | typescript | >=4.0.0 | | √ | |
22
24
  | @typescript-eslint/eslint-plugin | >=5.0.0 | | √ | |
23
25
  | @typescript-eslint/parser | >=5.0.0 | | √ |
26
+ | eslint-import-resolver-typescript | >=3.5.0 | | √ | |
24
27
  | eslint-plugin-vue | >=9.0.0 | | | √ |
25
28
  | vue-eslint-parser | >=9.0.0 | | | √ |
26
29
  | @vue/eslint-config-standard | >=8.0.0 | | | √ |
package/lib/for-js.js CHANGED
@@ -16,114 +16,51 @@ module.exports = {
16
16
  es6: true
17
17
  },
18
18
  plugins: [
19
- 'promise',
20
- 'sonarjs'
19
+ 'promise'
21
20
  ],
22
21
  extends: [
23
22
  'eslint:recommended',
23
+ 'standard',
24
24
  'plugin:import/recommended',
25
25
  'plugin:sonarjs/recommended'
26
26
  ],
27
27
  rules: {
28
28
  'no-debugger': devWarnProdError,
29
-
30
- // 基本
31
29
  'semi': ['error', 'always'],
32
- 'indent': ['error', 2, {
33
- 'SwitchCase': 1
34
- }],
35
- 'brace-style': ['error', '1tbs', {
36
- 'allowSingleLine': true
37
- }],
38
- 'quotes': ['error', 'single'],
39
-
40
- // 变量
41
- 'new-cap': 'error',
42
30
  'camelcase': 'error',
31
+ 'no-unused-vars': [devWarnProdError, {
32
+ vars: 'all',
33
+ args: 'after-used',
34
+ ignoreRestSiblings: true,
35
+ caughtErrors: 'none'
36
+ }],
43
37
  'no-use-before-define': ['error', {
44
38
  functions: false,
45
39
  classes: false,
46
40
  variables: true
47
41
  }],
48
- 'no-unused-vars': [devWarnProdError, {
49
- vars: 'all',
50
- args: 'after-used'
51
- }],
52
-
53
- // 空白与换行
54
- 'semi-spacing': 'error',
55
- 'array-bracket-spacing': ['error', 'never'],
56
- 'block-spacing': ['error', 'always'],
57
- 'computed-property-spacing': 'error',
58
- 'comma-spacing': 'error',
59
- 'func-call-spacing': 'error',
60
- 'key-spacing': 'error',
61
- 'keyword-spacing': 'error',
62
- 'no-trailing-spaces': 'error',
63
- 'no-whitespace-before-property': 'error',
64
- 'space-before-blocks': 'error',
65
42
  'space-before-function-paren': ['error', {
66
43
  anonymous: 'never',
67
44
  named: 'never',
68
45
  asyncArrow: 'always'
69
46
  }],
70
- 'space-in-parens': 'error',
71
- 'space-infix-ops': 'error',
72
- 'space-unary-ops': 'error',
73
- 'spaced-comment': ['error', 'always', {
74
- 'block': {
75
- 'markers': ['!'],
76
- 'balanced': true
77
- }
78
- }],
79
- 'object-curly-spacing': ['error', 'always'],
80
- 'object-property-newline': ['error', {
81
- allowAllPropertiesOnSameLine: true
82
- }],
83
47
  'operator-linebreak': ['error', 'after'],
84
- 'eol-last': ['error', 'always'],
85
48
  'padded-blocks': 'off',
86
-
87
- // 逗号
88
49
  'comma-dangle': ['error', 'only-multiline'],
89
- 'comma-style': 'error',
90
-
91
- // 其他
92
- 'no-extra-bind': 'error',
93
- 'no-extra-label': 'error',
94
- 'no-floating-decimal': 'error',
95
- 'no-implied-eval': 'error',
96
- 'no-iterator': 'error',
97
50
  'no-loop-func': 'error',
98
- 'no-multi-spaces': 'error',
99
- 'no-proto': 'error',
100
51
  'no-script-url': 'error',
101
- 'no-throw-literal': 'error',
102
- 'no-useless-call': 'error',
103
52
  'no-new': 'off',
104
- 'no-with': 'error',
105
53
  'no-constant-condition': devWarnProdError,
106
- 'no-cond-assign': ['error', 'except-parens'],
107
- 'no-empty': [devWarnProdError, {
108
- 'allowEmptyCatch': true
109
- }],
54
+ 'no-empty': [devWarnProdError, { 'allowEmptyCatch': true }],
110
55
  'no-lonely-if': 'off',
111
- 'curly': ['error', 'multi-line'],
112
56
  'wrap-iife': ['error', 'inside'],
113
- 'import/no-unresolved': 'off',
114
-
115
- // ES6
116
57
  'no-var': 'error',
117
- 'prefer-const': 'error',
118
- 'no-duplicate-imports': 'error',
119
58
  'prefer-promise-reject-errors': 'error',
120
- 'template-curly-spacing': ['error', 'never'],
121
59
  'no-template-curly-in-string': 'off',
122
- 'arrow-spacing': 'error',
123
60
  'no-confusing-arrow': 'error',
61
+ 'import/no-unresolved': 'off',
62
+ 'import/no-duplicates': 'error',
124
63
  'promise/prefer-await-to-then': 'error',
125
-
126
- // SonarJS
127
64
  'sonarjs/cognitive-complexity': ['error', 18],
128
65
  'sonarjs/no-duplicate-string': ['error', 5],
129
66
  'sonarjs/prefer-single-boolean-return': 'off',
package/lib/for-ts.js CHANGED
@@ -7,26 +7,50 @@ const { devWarnProdError } = require('./util');
7
7
  module.exports = {
8
8
  overrides: [{
9
9
  files: ['*.ts', '*.tsx'],
10
- parser: '@typescript-eslint/parser',
11
- plugins: [
12
- '@typescript-eslint'
13
- ],
14
10
  extends: [
15
- 'plugin:@typescript-eslint/recommended'
11
+ 'plugin:@typescript-eslint/recommended',
12
+ 'plugin:import/typescript'
16
13
  ],
17
14
  rules: {
18
15
  'semi': 'off',
19
- 'indent': 'off',
20
- 'no-use-before-define': 'off',
21
- 'no-unused-vars': 'off',
22
- 'comma-spacing': 'off',
23
- 'import/named': 'off',
24
16
  '@typescript-eslint/semi': ['error', 'always'],
17
+
18
+ 'indent': 'off',
25
19
  '@typescript-eslint/indent': ['error', 2, {
26
20
  'SwitchCase': 1
27
21
  }],
22
+
23
+ 'comma-spacing': 'off',
28
24
  '@typescript-eslint/comma-spacing': ['error'],
29
- '@typescript-eslint/no-duplicate-imports': ['error'],
25
+
26
+ 'comma-dangle': 'off',
27
+ '@typescript-eslint/comma-dangle': ['error', 'only-multiline'],
28
+
29
+ 'no-use-before-define': 'off',
30
+ '@typescript-eslint/no-use-before-define': ['error', {
31
+ 'functions': false,
32
+ 'classes': false,
33
+ 'variables': true
34
+ }],
35
+
36
+ 'no-unused-vars': 'off',
37
+ '@typescript-eslint/no-unused-vars': [devWarnProdError, {
38
+ vars: 'all',
39
+ args: 'after-used',
40
+ ignoreRestSiblings: true,
41
+ caughtErrors: 'none'
42
+ }],
43
+
44
+ 'no-loop-func': 'off',
45
+ '@typescript-eslint/no-loop-func': 'error',
46
+
47
+ 'space-before-function-paren': 'off',
48
+ '@typescript-eslint/space-before-function-paren': ['error', {
49
+ anonymous: 'never',
50
+ named: 'never',
51
+ asyncArrow: 'always'
52
+ }],
53
+
30
54
  '@typescript-eslint/no-empty-function': 'off',
31
55
  '@typescript-eslint/no-empty-interface': 'off',
32
56
  '@typescript-eslint/type-annotation-spacing': ['error', {
@@ -39,17 +63,22 @@ module.exports = {
39
63
  }
40
64
  }
41
65
  }],
42
- '@typescript-eslint/no-var-requires': 'off',
43
- '@typescript-eslint/no-unused-vars': [devWarnProdError, {
44
- vars: 'all',
45
- args: 'after-used'
46
- }],
47
- '@typescript-eslint/no-use-before-define': ['error', {
48
- 'functions': false,
49
- 'classes': false,
50
- 'variables': true
66
+ '@typescript-eslint/explicit-module-boundary-types': devWarnProdError,
67
+ '@typescript-eslint/naming-convention': ['warn', {
68
+ selector: 'enumMember',
69
+ format: ['UPPER_CASE']
70
+ }, {
71
+ selector: 'enum',
72
+ format: ['PascalCase']
51
73
  }],
52
- '@typescript-eslint/explicit-module-boundary-types': devWarnProdError
74
+ '@typescript-eslint/no-var-requires': 'off',
75
+ '@typescript-eslint/no-for-in-array': 'error'
76
+ },
77
+ settings: {
78
+ 'import/resolver': {
79
+ typescript: true,
80
+ node: true
81
+ }
53
82
  }
54
83
  }]
55
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polyv/eslint-config",
3
- "version": "0.6.0-beta.3",
3
+ "version": "0.6.0-beta.5",
4
4
  "description": "Standard ESLint configuration for Polyv projects.",
5
5
  "keywords": [
6
6
  "polyv",
@@ -16,8 +16,10 @@
16
16
  "@typescript-eslint/parser": ">=5.0.0",
17
17
  "@vue/eslint-config-standard": ">=8.0.0",
18
18
  "eslint": ">=8.0.0",
19
+ "eslint-config-standard": "17.0.0",
20
+ "eslint-import-resolver-typescript": ">=3.5.0",
19
21
  "eslint-plugin-import": ">=2.0.0",
20
- "eslint-plugin-node": ">=11.1.0",
22
+ "eslint-plugin-n": ">=15.7.0",
21
23
  "eslint-plugin-promise": ">=6.1.0",
22
24
  "eslint-plugin-sonarjs": ">=0.18.0",
23
25
  "eslint-plugin-vue": ">=9.0.0",
@@ -27,15 +29,21 @@
27
29
  "devDependencies": {
28
30
  "@babel/core": "^7.21.4",
29
31
  "@babel/eslint-parser": "^7.21.3",
30
- "@typescript-eslint/eslint-plugin": "^5.59.1",
32
+ "@typescript-eslint/eslint-plugin": "^5.59.2",
31
33
  "@typescript-eslint/parser": "^5.59.1",
32
34
  "@vue/eslint-config-standard": "^8.0.1",
33
35
  "eslint": "^8.39.0",
36
+ "eslint-config-standard": "^17.0.0",
37
+ "eslint-import-resolver-typescript": "^3.5.5",
34
38
  "eslint-plugin-import": "^2.27.5",
39
+ "eslint-plugin-n": "^15.7.0",
35
40
  "eslint-plugin-promise": "^6.1.1",
36
41
  "eslint-plugin-sonarjs": "^0.19.0",
37
42
  "eslint-plugin-vue": "^9.11.0",
38
43
  "typescript": "^5.0.4",
39
44
  "vue-eslint-parser": "^9.1.1"
45
+ },
46
+ "scripts": {
47
+ "print-config": "eslint --print-config ./lib/for-vue.js > config.txt"
40
48
  }
41
49
  }