@gitlab/eslint-plugin 21.4.1 → 22.0.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +223 -0
  2. package/README.md +16 -11
  3. package/docs/development.md +2 -1
  4. package/docs/rules/vue-no-popover-target-dollar-el.md +69 -0
  5. package/docs/rules.md +1 -0
  6. package/docs/usage.md +158 -47
  7. package/eslint9/index.js +6 -7
  8. package/lib/configs/base/best-practices.js +0 -4
  9. package/lib/configs/base/es6.js +0 -12
  10. package/lib/configs/base/imports.js +0 -9
  11. package/lib/configs/base/node.js +0 -4
  12. package/lib/confusing-browser-globals.js +68 -0
  13. package/lib/flat-configs/base.js +122 -0
  14. package/lib/flat-configs/default.js +13 -0
  15. package/lib/flat-configs/i18n.js +14 -0
  16. package/lib/flat-configs/jest.js +20 -0
  17. package/lib/flat-configs/tailwind.js +19 -0
  18. package/{eslint9/configs → lib/flat-configs}/typescript.js +47 -62
  19. package/lib/flat-configs/vue.js +16 -0
  20. package/lib/index.js +30 -38
  21. package/lib/plugin.js +32 -0
  22. package/lib/prettier-rules.js +10 -0
  23. package/lib/rules/no-runtime-template-compiler.js +5 -2
  24. package/lib/rules/vue-no-new-non-primitive-in-template.js +1 -1
  25. package/lib/rules/vue-no-popover-target-dollar-el.js +156 -0
  26. package/lib/rules/vue-no-undef-apollo-properties.js +1 -1
  27. package/lib/rules/vue-prefer-dollar-scopedslots.js +1 -1
  28. package/lib/rules/vue-require-required-key.js +1 -1
  29. package/lib/rules/vue-slot-name-casing.js +2 -2
  30. package/lib/vue-fragments.js +111 -0
  31. package/package.json +29 -11
  32. package/scripts/generateRuleMapFixtures.js +75 -0
  33. package/scripts/helpers/getConfigs.js +13 -6
  34. package/scripts/integration_test/bootstrap.sh +1 -1
  35. package/scripts/updateFiles.js +30 -6
  36. package/eslint9/configs/base.js +0 -140
  37. package/lib/configs/base.js +0 -115
  38. package/lib/configs/default.js +0 -17
  39. package/lib/configs/i18n.js +0 -10
  40. package/lib/configs/jest.js +0 -21
  41. package/lib/configs/tailwind.js +0 -10
  42. package/lib/configs/typescript.js +0 -95
  43. package/lib/configs/vue.js +0 -90
@@ -1,140 +0,0 @@
1
- const confusingBrowserGlobals = require('confusing-browser-globals');
2
- const globals = require('globals');
3
- const unicornPlugin = require('eslint-plugin-unicorn');
4
- const promisePlugin = require('eslint-plugin-promise');
5
- const importPlugin = require('eslint-plugin-import');
6
-
7
- // Import all the base configurations
8
- const bestPracticesConfig = require('../../lib/configs/base/best-practices');
9
- const errorsConfig = require('../../lib/configs/base/errors');
10
- const nodeConfig = require('../../lib/configs/base/node');
11
- const styleConfig = require('../../lib/configs/base/style');
12
- const variablesConfig = require('../../lib/configs/base/variables');
13
- const es6Config = require('../../lib/configs/base/es6');
14
- const importsConfig = require('../../lib/configs/base/imports');
15
- const strictConfig = require('../../lib/configs/base/strict');
16
-
17
- /*
18
- This plugin contains rules related to GitLab JavaScript style guide
19
- Vue specific rules are in lib/configs/vue.js
20
- */
21
- module.exports = {
22
- languageOptions: {
23
- globals: {
24
- ...globals.browser,
25
- ...globals.es2020,
26
- ...globals.node,
27
- ...globals.es6,
28
- },
29
- ecmaVersion: 'latest',
30
- sourceType: 'module',
31
- parserOptions: {
32
- parser: 'espree',
33
- },
34
- },
35
- plugins: {
36
- unicorn: unicornPlugin,
37
- promise: promisePlugin,
38
- import: importPlugin,
39
- },
40
- settings: {
41
- // Merge import settings from imports config
42
- ...importsConfig.settings,
43
- },
44
- rules: {
45
- ...promisePlugin.configs['flat/recommended'].rules,
46
- // Merge all rules from the base configurations
47
- ...bestPracticesConfig.rules,
48
- ...errorsConfig.rules,
49
- ...nodeConfig.rules,
50
- ...styleConfig.rules,
51
- ...variablesConfig.rules,
52
- ...es6Config.rules,
53
- ...importsConfig.rules,
54
- ...strictConfig.rules,
55
- // Override specific rules from base configs
56
- // Promise rule customizations
57
- 'promise/catch-or-return': [
58
- 'error',
59
- {
60
- allowFinally: true,
61
- },
62
- ],
63
- camelcase: [
64
- 'error',
65
- {
66
- properties: 'never',
67
- ignoreDestructuring: true,
68
- },
69
- ],
70
- 'default-param-last': 'off',
71
- 'arrow-body-style': 'off',
72
- 'unicorn/filename-case': ['error', { case: 'snakeCase' }],
73
- 'unicorn/no-array-callback-reference': 'error',
74
- 'import/prefer-default-export': 'off',
75
- 'import/no-default-export': 'error',
76
- 'import/no-deprecated': 'error',
77
- 'import/no-dynamic-require': ['error', { esmodule: true }],
78
- 'no-implicit-coercion': [
79
- 'error',
80
- {
81
- boolean: true,
82
- number: true,
83
- string: true,
84
- },
85
- ],
86
- 'no-param-reassign': [
87
- 'error',
88
- {
89
- props: true,
90
- ignorePropertyModificationsFor: ['acc', 'accumulator', 'el', 'element', 'state'],
91
- },
92
- ],
93
- 'no-restricted-exports': [
94
- 'error',
95
- {
96
- restrictedNamedExports: [
97
- 'then', // avoid confusion when used with dynamic `import()` promise
98
- ],
99
- },
100
- ],
101
- 'no-restricted-syntax': 'off',
102
- 'no-sequences': [
103
- 'error',
104
- {
105
- allowInParentheses: false,
106
- },
107
- ],
108
- 'no-restricted-globals': [
109
- 'error',
110
- {
111
- name: 'isFinite',
112
- message:
113
- 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
114
- },
115
- {
116
- name: 'isNaN',
117
- message:
118
- 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
119
- },
120
- {
121
- name: 'escape',
122
- message:
123
- "The global `escape` function is unsafe. Did you mean to use `encodeURI`, `encodeURIComponent` or lodash's `escape` instead?",
124
- },
125
- {
126
- name: 'unescape',
127
- message:
128
- "The global `unescape` function is unsafe. Did you mean to use `decodeURI`, `decodeURIComponent` or lodash's `unescape` instead?",
129
- },
130
- ].concat(confusingBrowserGlobals),
131
- 'import/order': [
132
- 'error',
133
- {
134
- groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
135
- },
136
- ],
137
- // https://docs.gitlab.com/ee/development/fe_guide/style/javascript.html#limit-number-of-parameters
138
- 'max-params': ['error', { max: 3 }],
139
- },
140
- };
@@ -1,115 +0,0 @@
1
- const confusingBrowserGlobals = require('confusing-browser-globals');
2
-
3
- /*
4
- This plugin contains rules related to GitLab JavaScript style guide
5
- Vue specific rules are in lib/configs/vue.js
6
- */
7
- module.exports = {
8
- env: {
9
- browser: true,
10
- es2020: true,
11
- },
12
- extends: [
13
- ...[
14
- './base/best-practices.js',
15
- './base/errors',
16
- './base/node',
17
- './base/style',
18
- './base/variables',
19
- './base/es6',
20
- './base/imports',
21
- './base/strict',
22
- ].map((f) => require.resolve(f)),
23
- 'prettier',
24
- 'plugin:promise/recommended',
25
- ],
26
- parserOptions: {
27
- parser: 'espree',
28
- ecmaVersion: 'latest',
29
- },
30
- plugins: ['unicorn', 'promise', 'import', '@gitlab'],
31
- rules: {
32
- camelcase: [
33
- 'error',
34
- {
35
- properties: 'never',
36
- ignoreDestructuring: true,
37
- },
38
- ],
39
- 'default-param-last': 'off',
40
- 'arrow-body-style': 'off',
41
- 'unicorn/filename-case': ['error', { case: 'snakeCase' }],
42
- 'unicorn/no-array-callback-reference': 'error',
43
- 'import/prefer-default-export': 'off',
44
- 'import/no-default-export': 'error',
45
- 'import/no-deprecated': 'error',
46
- 'import/no-dynamic-require': ['error', { esmodule: true }],
47
- 'no-implicit-coercion': [
48
- 'error',
49
- {
50
- boolean: true,
51
- number: true,
52
- string: true,
53
- },
54
- ],
55
- 'no-param-reassign': [
56
- 'error',
57
- {
58
- props: true,
59
- ignorePropertyModificationsFor: ['acc', 'accumulator', 'el', 'element', 'state'],
60
- },
61
- ],
62
- 'no-restricted-exports': [
63
- 'error',
64
- {
65
- restrictedNamedExports: [
66
- 'then', // avoid confusion when used with dynamic `import()` promise
67
- ],
68
- },
69
- ],
70
- 'no-restricted-syntax': 'off',
71
- 'no-sequences': [
72
- 'error',
73
- {
74
- allowInParentheses: false,
75
- },
76
- ],
77
- 'promise/catch-or-return': [
78
- 'error',
79
- {
80
- allowFinally: true,
81
- },
82
- ],
83
- 'no-restricted-globals': [
84
- 'error',
85
- {
86
- name: 'isFinite',
87
- message:
88
- 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
89
- },
90
- {
91
- name: 'isNaN',
92
- message:
93
- 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
94
- },
95
- {
96
- name: 'escape',
97
- message:
98
- "The global `escape` function is unsafe. Did you mean to use `encodeURI`, `encodeURIComponent` or lodash's `escape` instead?",
99
- },
100
- {
101
- name: 'unescape',
102
- message:
103
- "The global `unescape` function is unsafe. Did you mean to use `decodeURI`, `decodeURIComponent` or lodash's `unescape` instead?",
104
- },
105
- ].concat(confusingBrowserGlobals),
106
- 'import/order': [
107
- 'error',
108
- {
109
- groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
110
- },
111
- ],
112
- // https://docs.gitlab.com/ee/development/fe_guide/style/javascript.html#limit-number-of-parameters
113
- 'max-params': ['error', { max: 3 }],
114
- },
115
- };
@@ -1,17 +0,0 @@
1
- const baseConfig = require('./base');
2
- const vueConfig = require('./vue');
3
-
4
- module.exports = {
5
- ...baseConfig,
6
- extends: [
7
- ...baseConfig.extends,
8
- 'prettier',
9
- 'plugin:promise/recommended',
10
- 'plugin:vue/recommended',
11
- ],
12
- rules: {
13
- ...baseConfig.rules,
14
- ...vueConfig.rules,
15
- },
16
- overrides: vueConfig.overrides,
17
- };
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- plugins: ['@gitlab'],
3
- rules: {
4
- '@gitlab/require-i18n-strings': 'error',
5
- '@gitlab/vue-require-i18n-attribute-strings': 'error',
6
- '@gitlab/vue-require-i18n-strings': 'error',
7
- '@gitlab/require-valid-i18n-helpers': 'error',
8
- '@gitlab/vue-require-valid-i18n-helpers': 'error',
9
- },
10
- };
@@ -1,21 +0,0 @@
1
- module.exports = {
2
- extends: ['plugin:jest/recommended'],
3
- rules: {
4
- 'jest/consistent-test-it': ['error', { fn: 'it', withinDescribe: 'it' }],
5
- 'jest/no-conditional-expect': 'off',
6
- 'jest/valid-title': [
7
- 'error',
8
- {
9
- ignoreTypeOfDescribeName: true,
10
- },
11
- ],
12
- 'jest/no-restricted-matchers': [
13
- 'error',
14
- {
15
- toBeFalsy: 'Prefer a stronger matcher like `toBe(false)`',
16
- toBeTruthy: 'Prefer a stronger matcher like `toBe(true)`',
17
- },
18
- ],
19
- 'jest/prefer-to-have-length': 'error',
20
- },
21
- };
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- plugins: ['@gitlab', 'tailwindcss'],
3
- rules: {
4
- '@gitlab/tailwind-no-interpolation': 'error',
5
- '@gitlab/vue-tailwind-no-interpolation': 'error',
6
- '@gitlab/tailwind-no-max-width-media-queries': 'error',
7
- '@gitlab/vue-tailwind-no-max-width-media-queries': 'error',
8
- 'tailwindcss/no-arbitrary-value': 'error',
9
- },
10
- };
@@ -1,95 +0,0 @@
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
- 'max-params': 'off',
41
- 'no-throw-literal': 'off',
42
- 'no-shadow': 'off',
43
- 'no-empty-function': 'off',
44
- 'no-plusplus': 'off',
45
- 'unicorn/no-array-callback-reference': 'off',
46
- '@typescript-eslint/no-throw-literal': 'error',
47
- '@typescript-eslint/no-unused-vars': 'error',
48
- '@typescript-eslint/no-shadow': 'error',
49
- '@typescript-eslint/return-await': 'error',
50
- '@typescript-eslint/no-floating-promises': 'error',
51
- '@typescript-eslint/explicit-member-accessibility': [
52
- 'error',
53
- {
54
- accessibility: 'no-public',
55
- },
56
- ],
57
- 'class-methods-use-this': 'off',
58
- 'import/no-cycle': 'error',
59
- 'promise/param-names': 'off',
60
- 'no-use-before-define': ['warn', 'nofunc'],
61
- 'no-restricted-syntax': [
62
- 'error',
63
- {
64
- selector: ':matches(PropertyDefinition, MethodDefinition)[accessibility="private"]',
65
- message: 'Use # prefix instead of `private` to indicate private class members.',
66
- },
67
- {
68
- selector: 'ForInStatement',
69
- message:
70
- '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.',
71
- },
72
- {
73
- selector: 'LabeledStatement',
74
- message:
75
- 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
76
- },
77
- {
78
- selector: 'WithStatement',
79
- message:
80
- '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
81
- },
82
- ],
83
- },
84
- },
85
- {
86
- files: ['*.test.ts', '*.test.js'],
87
- rules: {
88
- 'max-classes-per-file': 'off',
89
- '@typescript-eslint/no-non-null-assertion': 'off',
90
- },
91
- },
92
- ],
93
- };
94
-
95
- module.exports = tsConfig;
@@ -1,90 +0,0 @@
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
- };