@gitlab/eslint-plugin 19.5.0 → 19.6.1

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/.tool-versions CHANGED
@@ -1,2 +1,2 @@
1
- nodejs 18.16.0
1
+ nodejs 20.13.1
2
2
  yarn 1.22.19
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [19.6.1](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v19.6.0...v19.6.1) (2024-08-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** update eslint-config-prettier to v9.1.0 ([25abb6c](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/25abb6c30d339f101bea37a4f8a762c5d399b402))
7
+ * **deps:** update eslint-plugin-import to v2.29.1 ([c6aa74d](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/c6aa74d6b137511b18af006e7134b557b9561825))
8
+ * **deps:** update eslint-plugin-jest to v28.6.0 ([3f0dfc8](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/3f0dfc8e43f9874dc661fdde93f8b4825874b6c6))
9
+ * **deps:** update eslint-plugin-promise to v7.0.0 ([be8a1db](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/be8a1db92fa09e2c042675dc5b655d685da1975d))
10
+ * **deps:** update eslint-plugin-unicorn to v55.0.0 ([aaf7b33](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/aaf7b3303f7909683132b94b4d0a804afb1ee07a))
11
+ * **deps:** update eslint-plugin-vue to v9.27.0 ([e8b81ef](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/e8b81efb7bf2b6e0fa5e6a73c3692afba076d596))
12
+ * **deps:** update vue-eslint-parser to v9.4.3 ([af7d91e](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/af7d91e37e939f47ba06f4906a3e3997edc96793))
13
+
14
+ # [19.6.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v19.5.0...v19.6.0) (2024-07-15)
15
+
16
+
17
+ ### Features
18
+
19
+ * **config:** add TypeScript configuration ([5f7c042](https://gitlab.com/gitlab-org/frontend/eslint-plugin/commit/5f7c0427f60c9778bdf799c2a883d083e5ec08de))
20
+
1
21
  # [19.5.0](https://gitlab.com/gitlab-org/frontend/eslint-plugin/compare/v19.4.0...v19.5.0) (2024-03-27)
2
22
 
3
23
 
@@ -0,0 +1,93 @@
1
+ const [, ...restrictedGlobals] = require('eslint-config-airbnb-base/rules/variables').rules[
2
+ 'no-restricted-globals'
3
+ ];
4
+
5
+ /*
6
+ This plugin contains rules related to GitLab JavaScript style guide
7
+ Vue specific rules are in lib/configs/vue.js
8
+ */
9
+ module.exports = {
10
+ env: {
11
+ browser: true,
12
+ es2020: true,
13
+ },
14
+ extends: ['airbnb-base', 'prettier', 'plugin:promise/recommended'],
15
+ parserOptions: {
16
+ parser: 'espree',
17
+ ecmaVersion: 'latest',
18
+ },
19
+ plugins: ['unicorn', 'promise', 'import', '@gitlab'],
20
+ rules: {
21
+ camelcase: [
22
+ 'error',
23
+ {
24
+ properties: 'never',
25
+ ignoreDestructuring: true,
26
+ },
27
+ ],
28
+ 'default-param-last': 'off',
29
+ 'arrow-body-style': 'off',
30
+ 'unicorn/filename-case': ['error', { case: 'snakeCase' }],
31
+ 'unicorn/no-array-callback-reference': 'error',
32
+ 'import/prefer-default-export': 'off',
33
+ 'import/no-default-export': 'error',
34
+ 'import/no-deprecated': 'error',
35
+ 'import/no-dynamic-require': ['error', { esmodule: true }],
36
+ 'no-implicit-coercion': [
37
+ 'error',
38
+ {
39
+ boolean: true,
40
+ number: true,
41
+ string: true,
42
+ },
43
+ ],
44
+ 'no-param-reassign': [
45
+ 'error',
46
+ {
47
+ props: true,
48
+ ignorePropertyModificationsFor: ['acc', 'accumulator', 'el', 'element', 'state'],
49
+ },
50
+ ],
51
+ 'no-restricted-exports': [
52
+ 'error',
53
+ {
54
+ restrictedNamedExports: [
55
+ 'then', // avoid confusion when used with dynamic `import()` promise
56
+ ],
57
+ },
58
+ ],
59
+ 'no-restricted-syntax': 'off',
60
+ 'no-sequences': [
61
+ 'error',
62
+ {
63
+ allowInParentheses: false,
64
+ },
65
+ ],
66
+ 'promise/catch-or-return': [
67
+ 'error',
68
+ {
69
+ allowFinally: true,
70
+ },
71
+ ],
72
+ 'no-restricted-globals': [
73
+ 'error',
74
+ ...restrictedGlobals,
75
+ {
76
+ name: 'escape',
77
+ message:
78
+ "The global `escape` function is unsafe. Did you mean to use `encodeURI`, `encodeURIComponent` or lodash's `escape` instead?",
79
+ },
80
+ {
81
+ name: 'unescape',
82
+ message:
83
+ "The global `unescape` function is unsafe. Did you mean to use `decodeURI`, `decodeURIComponent` or lodash's `unescape` instead?",
84
+ },
85
+ ],
86
+ 'import/order': [
87
+ 'error',
88
+ {
89
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
90
+ },
91
+ ],
92
+ },
93
+ };
@@ -1,150 +1,17 @@
1
- const [, ...restrictedGlobals] = require('eslint-config-airbnb-base/rules/variables').rules[
2
- 'no-restricted-globals'
3
- ];
1
+ const baseConfig = require('./base');
2
+ const vueConfig = require('./vue');
4
3
 
5
4
  module.exports = {
6
- env: {
7
- browser: true,
8
- es2020: true,
9
- },
5
+ ...baseConfig,
10
6
  extends: [
11
7
  'airbnb-base',
12
- 'plugin:vue/recommended',
13
8
  'prettier',
14
- 'prettier/vue',
15
9
  'plugin:promise/recommended',
10
+ 'plugin:vue/recommended',
16
11
  ],
17
- parserOptions: {
18
- parser: 'espree',
19
- ecmaVersion: 'latest',
20
- },
21
- plugins: ['unicorn', 'promise', 'import', '@gitlab'],
22
12
  rules: {
23
- camelcase: [
24
- 'error',
25
- {
26
- properties: 'never',
27
- ignoreDestructuring: true,
28
- },
29
- ],
30
- 'default-param-last': 'off',
31
- 'unicorn/filename-case': ['error', { case: 'snakeCase' }],
32
- 'unicorn/no-array-callback-reference': 'error',
33
- 'import/prefer-default-export': 'off',
34
- 'import/no-default-export': 'error',
35
- 'import/no-deprecated': 'error',
36
- 'import/no-dynamic-require': ['error', { esmodule: true }],
37
- 'no-implicit-coercion': [
38
- 'error',
39
- {
40
- boolean: true,
41
- number: true,
42
- string: true,
43
- },
44
- ],
45
- 'no-param-reassign': [
46
- 'error',
47
- {
48
- props: true,
49
- ignorePropertyModificationsFor: ['acc', 'accumulator', 'el', 'element', 'state'],
50
- },
51
- ],
52
- 'no-restricted-exports': [
53
- 'error',
54
- {
55
- restrictedNamedExports: [
56
- 'then', // avoid confusion when used with dynamic `import()` promise
57
- ],
58
- },
59
- ],
60
- 'no-restricted-syntax': 'off',
61
- 'no-sequences': [
62
- 'error',
63
- {
64
- allowInParentheses: false,
65
- },
66
- ],
67
- 'promise/catch-or-return': [
68
- 'error',
69
- {
70
- allowFinally: true,
71
- },
72
- ],
73
- 'vue/html-self-closing': [
74
- 'error',
75
- {
76
- html: {
77
- void: 'any',
78
- normal: 'never',
79
- component: 'always',
80
- },
81
- svg: 'always',
82
- math: 'always',
83
- },
84
- ],
85
- 'vue/component-tags-order': [
86
- 'error',
87
- {
88
- order: ['script', 'template', 'style'],
89
- },
90
- ],
91
- 'vue/component-options-name-casing': ['error', 'PascalCase'],
92
- 'vue/component-name-in-template-casing': ['error', 'kebab-case'],
93
- '@gitlab/vue-require-required-key': 'error',
94
- 'no-restricted-globals': [
95
- 'error',
96
- ...restrictedGlobals,
97
- {
98
- name: 'escape',
99
- message:
100
- "The global `escape` function is unsafe. Did you mean to use `encodeURI`, `encodeURIComponent` or lodash's `escape` instead?",
101
- },
102
- {
103
- name: 'unescape',
104
- message:
105
- "The global `unescape` function is unsafe. Did you mean to use `decodeURI`, `decodeURIComponent` or lodash's `unescape` instead?",
106
- },
107
- ],
108
- 'vue/v-slot-style': [
109
- 'error',
110
- {
111
- atComponent: 'shorthand',
112
- },
113
- ],
114
- '@gitlab/vue-no-data-toggle': 'error',
115
- '@gitlab/vue-prefer-dollar-scopedslots': 'error',
116
- '@gitlab/vue-slot-name-casing': 'error',
117
- '@gitlab/no-runtime-template-compiler': 'error',
118
- 'import/order': [
119
- 'error',
120
- {
121
- groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
122
- },
123
- ],
124
- // See https://gitlab.com/gitlab-org/frontend/eslint-plugin/-/issues/52.
125
- 'vue/component-api-style': ['error', ['options']],
126
- // BEGIN rules to aid migration from Vue 2.x to 3.x.
127
- // See https://gitlab.com/groups/gitlab-org/-/epics/3174 for more details.
128
- 'vue/no-deprecated-data-object-declaration': 'error',
129
- 'vue/no-deprecated-events-api': 'error',
130
- 'vue/no-deprecated-filter': 'error',
131
- 'vue/no-deprecated-functional-template': 'error',
132
- 'vue/no-deprecated-html-element-is': 'error',
133
- 'vue/no-deprecated-inline-template': 'error',
134
- 'vue/no-deprecated-props-default-this': 'error',
135
- 'vue/no-deprecated-scope-attribute': 'error',
136
- 'vue/no-deprecated-slot-attribute': 'error',
137
- 'vue/no-deprecated-slot-scope-attribute': 'error',
138
- 'vue/no-deprecated-v-on-number-modifiers': 'error',
139
- 'vue/no-deprecated-vue-config-keycodes': 'error',
140
- // END rules to aid migration from Vue 2.x to 3.x.
13
+ ...baseConfig.rules,
14
+ ...vueConfig.rules,
141
15
  },
142
- overrides: [
143
- {
144
- files: ['**/*.vue'],
145
- rules: {
146
- 'import/no-default-export': 'off',
147
- },
148
- },
149
- ],
16
+ overrides: vueConfig.overrides,
150
17
  };
@@ -0,0 +1,88 @@
1
+ const baseConfig = require('./base');
2
+
3
+ const tsConfig = {
4
+ env: {
5
+ mocha: true,
6
+ jest: true,
7
+ },
8
+ parserOptions: baseConfig.parserOptions,
9
+ extends: [...baseConfig.extends],
10
+ plugins: [...baseConfig.plugins],
11
+ rules: {
12
+ ...baseConfig.rules,
13
+ 'import/extensions': [
14
+ 'error',
15
+ 'ignorePackages',
16
+ {
17
+ js: 'never',
18
+ jsx: 'never',
19
+ ts: 'never',
20
+ tsx: 'never',
21
+ },
22
+ ],
23
+ },
24
+ overrides: [
25
+ {
26
+ files: ['**/*.ts'],
27
+ parserOptions: {
28
+ parser: '@typescript-eslint/parser',
29
+ project: ['./tsconfig.json'],
30
+ },
31
+ plugins: ['@typescript-eslint', 'import'],
32
+ extends: [
33
+ 'eslint:recommended',
34
+ 'plugin:@typescript-eslint/strict',
35
+ 'plugin:import/typescript',
36
+ ],
37
+ reportUnusedDisableDirectives: true,
38
+ rules: {
39
+ semi: [2, 'always'],
40
+ 'no-throw-literal': 'off',
41
+ 'no-shadow': 'off',
42
+ 'no-empty-function': 'off',
43
+ 'no-plusplus': 'off',
44
+ 'unicorn/no-array-callback-reference': 'off',
45
+ '@typescript-eslint/no-throw-literal': 'error',
46
+ '@typescript-eslint/no-unused-vars': 'error',
47
+ '@typescript-eslint/no-shadow': 'error',
48
+ '@typescript-eslint/return-await': 'error',
49
+ '@typescript-eslint/no-floating-promises': 'error',
50
+ 'class-methods-use-this': 'off',
51
+ 'import/no-cycle': 'error',
52
+ 'promise/param-names': 'off',
53
+ 'no-use-before-define': ['warn', 'nofunc'],
54
+ 'no-restricted-syntax': [
55
+ 'error',
56
+ {
57
+ selector: ':matches(PropertyDefinition, MethodDefinition)[accessibility="private"]',
58
+ message: 'Use # prefix instead of `private` to indicate private class members.',
59
+ },
60
+ {
61
+ selector: 'ForInStatement',
62
+ message:
63
+ 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
64
+ },
65
+ {
66
+ selector: 'LabeledStatement',
67
+ message:
68
+ 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
69
+ },
70
+ {
71
+ selector: 'WithStatement',
72
+ message:
73
+ '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
74
+ },
75
+ ],
76
+ },
77
+ },
78
+ {
79
+ files: ['*.test.ts', '*.test.js'],
80
+ rules: {
81
+ 'max-classes-per-file': 'off',
82
+ '@typescript-eslint/no-non-null-assertion': 'off',
83
+ },
84
+ },
85
+ ],
86
+ };
87
+
88
+ module.exports = tsConfig;
@@ -0,0 +1,90 @@
1
+ /*
2
+ This plugin contains rules related to GitLab Vue style guide
3
+ base JavaScript rules are in lib/configs/base.js
4
+ */
5
+
6
+ module.exports = {
7
+ env: {
8
+ browser: true,
9
+ es2020: true,
10
+ },
11
+ extends: ['plugin:vue/recommended', 'prettier'],
12
+ parserOptions: {
13
+ parser: 'espree',
14
+ ecmaVersion: 'latest',
15
+ },
16
+ plugins: ['unicorn', 'promise', 'import', '@gitlab'],
17
+ rules: {
18
+ 'vue/html-self-closing': [
19
+ 'error',
20
+ {
21
+ html: {
22
+ void: 'any',
23
+ normal: 'never',
24
+ component: 'always',
25
+ },
26
+ svg: 'always',
27
+ math: 'always',
28
+ },
29
+ ],
30
+ 'vue/component-tags-order': [
31
+ 'error',
32
+ {
33
+ order: ['script', 'template', 'style'],
34
+ },
35
+ ],
36
+ // Turning this off for now as we violate this rule in many places.
37
+ 'vue/max-attributes-per-line': 'off',
38
+ 'vue/component-options-name-casing': ['error', 'PascalCase'],
39
+ 'vue/component-name-in-template-casing': ['error', 'kebab-case'],
40
+ '@gitlab/vue-require-required-key': 'error',
41
+ 'vue/v-slot-style': [
42
+ 'error',
43
+ {
44
+ atComponent: 'shorthand',
45
+ },
46
+ ],
47
+ '@gitlab/vue-no-data-toggle': 'error',
48
+ '@gitlab/vue-prefer-dollar-scopedslots': 'error',
49
+ '@gitlab/vue-slot-name-casing': 'error',
50
+ '@gitlab/no-runtime-template-compiler': 'error',
51
+ 'import/order': [
52
+ 'error',
53
+ {
54
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
55
+ },
56
+ ],
57
+ // See https://gitlab.com/gitlab-org/frontend/eslint-plugin/-/issues/52.
58
+ 'vue/component-api-style': ['error', ['options']],
59
+ // We might not want to enable vue/singleline-html-element-content-newline and vue/multiline-html-element-content-newline
60
+ // just yet as they might cause regression depending on how the consumers compile Vue templates.
61
+ 'vue/singleline-html-element-content-newline': 'off',
62
+ 'vue/multiline-html-element-content-newline': 'off',
63
+ // Disabling these as they might conflict with prettier.
64
+ 'vue/html-indent': 'off',
65
+ 'vue/html-closing-bracket-newline': 'off',
66
+ // BEGIN rules to aid migration from Vue 2.x to 3.x.
67
+ // See https://gitlab.com/groups/gitlab-org/-/epics/3174 for more details.
68
+ 'vue/no-deprecated-data-object-declaration': 'error',
69
+ 'vue/no-deprecated-events-api': 'error',
70
+ 'vue/no-deprecated-filter': 'error',
71
+ 'vue/no-deprecated-functional-template': 'error',
72
+ 'vue/no-deprecated-html-element-is': 'error',
73
+ 'vue/no-deprecated-inline-template': 'error',
74
+ 'vue/no-deprecated-props-default-this': 'error',
75
+ 'vue/no-deprecated-scope-attribute': 'error',
76
+ 'vue/no-deprecated-slot-attribute': 'error',
77
+ 'vue/no-deprecated-slot-scope-attribute': 'error',
78
+ 'vue/no-deprecated-v-on-number-modifiers': 'error',
79
+ 'vue/no-deprecated-vue-config-keycodes': 'error',
80
+ // END rules to aid migration from Vue 2.x to 3.x.
81
+ },
82
+ overrides: [
83
+ {
84
+ files: ['**/*.vue'],
85
+ rules: {
86
+ 'import/no-default-export': 'off',
87
+ },
88
+ },
89
+ ],
90
+ };
package/lib/index.js CHANGED
@@ -20,6 +20,9 @@ module.exports = {
20
20
  },
21
21
  configs: {
22
22
  default: require('./configs/default.js'),
23
+ typescript: require('./configs/typescript.js'),
24
+ base: require('./configs/base.js'),
25
+ vue: require('./configs/vue.js'),
23
26
  i18n: require('./configs/i18n.js'),
24
27
  jest: require('./configs/jest.js'),
25
28
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/eslint-plugin",
3
- "version": "19.5.0",
3
+ "version": "19.6.1",
4
4
  "description": "GitLab package for our custom eslint rules",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -30,25 +30,26 @@
30
30
  "node": ">=14"
31
31
  },
32
32
  "dependencies": {
33
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
33
34
  "eslint-config-airbnb-base": "^15.0.0",
34
- "eslint-config-prettier": "^6.10.0",
35
- "eslint-plugin-import": "^2.28.0",
36
- "eslint-plugin-jest": "^27.2.1",
37
- "eslint-plugin-promise": "^6.0.1",
38
- "eslint-plugin-unicorn": "^40.1.0",
39
- "eslint-plugin-vue": "^9.17.0",
35
+ "eslint-config-prettier": "^9.1.0",
36
+ "eslint-plugin-import": "^2.29.1",
37
+ "eslint-plugin-jest": "^28.6.0",
38
+ "eslint-plugin-promise": "^7.0.0",
39
+ "eslint-plugin-unicorn": "^55.0.0",
40
+ "eslint-plugin-vue": "^9.27.0",
41
+ "vue-eslint-parser": "^9.4.3",
40
42
  "lodash": "^4.17.21"
41
43
  },
42
44
  "peerDependencies": {
43
- "eslint": "^8.19.0"
45
+ "eslint": "^8.57.0"
44
46
  },
45
47
  "devDependencies": {
46
- "eslint": "^8.19.0",
48
+ "eslint": "^8.57.0",
47
49
  "glob": "^7.2.0",
48
50
  "jest": "^27.5.1",
49
51
  "prettier": "^2.6.1",
50
52
  "pretty-quick": "^3.1.3",
51
- "vue-eslint-parser": "^9.3.1",
52
53
  "yarn-deduplicate": "^6.0.2"
53
54
  },
54
55
  "release": {