@rebilly/eslint-config 4.9.2 → 4.10.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/README.md CHANGED
@@ -1,28 +1,68 @@
1
1
  # Rebilly shared eslint configs
2
2
 
3
- These are the shared eslint configs for all Rebilly frontend projects.
3
+ These are the shared ESLint 9 flat configs for all Rebilly frontend projects.
4
4
 
5
- Where possible, we should exclusively try to `extend` these configs, and
5
+ Where possible, we should exclusively try to spread these configs and
6
6
  avoid adding overrides in our projects. This will keep the projects consistent and
7
7
  reduce the difficulty when switching between projects.
8
8
 
9
9
  ## Usage
10
10
 
11
11
  1. Install the package in the project: `pnpm add -D @rebilly/eslint-config@workspace:*`
12
- 2. Extend the appropriate config in the project's `.eslintrc.js` file:
12
+ 2. Create an `eslint.config.cjs` file in the project root:
13
13
 
14
14
  ```js
15
- module.exports = {
16
- root: true,
17
- // Which config to extend depends on the project type, see below
18
- extends: ["@rebilly/eslint-config/vue"],
19
- };
15
+ const vueConfig = require('@rebilly/eslint-config/vue');
16
+
17
+ module.exports = [...vueConfig];
20
18
  ```
21
19
 
22
20
  ## Configs
23
21
 
24
- | Config | Extend | Description |
25
- | ---------- | ------------------------------------- | -------------------------------------------------------------------------------------- |
26
- | Base | `@rebilly/eslint-config` | Base config for all projects, containing generic Javascript and Prettier eslint rules. |
27
- | Typescript | `@rebilly/eslint-config/typescript` | TypeScript projects. |
28
- | Vue | `@rebilly/eslint-config/vue` | Vue projects written in TypeScript. |
22
+ | Config | Import | Description |
23
+ | ---------- | ----------------------------------------- | -------------------------------------------------------------------------------------- |
24
+ | Base | `@rebilly/eslint-config` | Base config for all projects, containing generic JavaScript and Vitest/Cypress rules. |
25
+ | TypeScript | `@rebilly/eslint-config/typescript` | TypeScript projects. |
26
+ | Vue | `@rebilly/eslint-config/vue` | Vue 3 projects written in TypeScript. |
27
+
28
+ ## Flat Config Format
29
+
30
+ ESLint 9 uses a flat config format. Key differences from the old `.eslintrc.*` format:
31
+
32
+ - No more `extends` - import and spread configs directly
33
+ - No more `env` - use `globals` package with `languageOptions.globals`
34
+ - No more `overrides` - use separate config objects with `files` property
35
+ - Explicit plugin imports instead of string references
36
+
37
+ ### Example with custom rules
38
+
39
+ ```js
40
+ const globals = require('globals');
41
+ const vueConfig = require('@rebilly/eslint-config/vue');
42
+
43
+ module.exports = [
44
+ ...vueConfig,
45
+ {
46
+ languageOptions: {
47
+ globals: {
48
+ ...globals.browser,
49
+ myGlobal: 'readonly',
50
+ },
51
+ },
52
+ rules: {
53
+ 'no-console': 'warn',
54
+ },
55
+ },
56
+ // Override for specific files
57
+ {
58
+ files: ['**/*.spec.ts'],
59
+ rules: {
60
+ 'no-console': 'off',
61
+ },
62
+ },
63
+ ];
64
+ ```
65
+
66
+ ## Prettier
67
+
68
+ Prettier is no longer integrated into ESLint. Run Prettier separately as a formatting tool.
package/index.cjs ADDED
@@ -0,0 +1,98 @@
1
+ const js = require('@eslint/js');
2
+ const cypress = require('eslint-plugin-cypress/flat');
3
+ const vitest = require('eslint-plugin-vitest');
4
+ const globals = require('globals');
5
+ const prettier = require('eslint-config-prettier');
6
+
7
+ /**
8
+ * Base ESLint flat config for JavaScript projects.
9
+ * Includes eslint:recommended, Cypress, and Vitest support.
10
+ */
11
+ module.exports = [
12
+ js.configs.recommended,
13
+ cypress.configs.recommended,
14
+ {
15
+ plugins: {
16
+ vitest,
17
+ },
18
+ languageOptions: {
19
+ ecmaVersion: 'latest',
20
+ sourceType: 'module',
21
+ globals: {
22
+ ...globals.es2021,
23
+ ...vitest.environments.env.globals,
24
+ },
25
+ },
26
+ rules: {
27
+ 'no-underscore-dangle': [
28
+ 'error',
29
+ { allow: ['_links', '_embedded', '_dev'] },
30
+ ],
31
+ 'no-lonely-if': 'error',
32
+ 'no-implicit-coercion': 'error',
33
+ // Disable prefer-const (new in eslint:recommended, not in original config)
34
+ 'prefer-const': 'off',
35
+ // Configure no-unused-vars to ignore caught errors (backward compatibility)
36
+ 'no-unused-vars': [
37
+ 'error',
38
+ {
39
+ varsIgnorePattern: '^_',
40
+ argsIgnorePattern: '^_',
41
+ caughtErrors: 'none',
42
+ },
43
+ ],
44
+ },
45
+ },
46
+ {
47
+ files: [
48
+ '**/.eslintrc.cjs',
49
+ '**/.eslintrc.js',
50
+ '**/.prettierrc.js',
51
+ '**/babel.config.js',
52
+ '**/cypress.config.js',
53
+ '**/cypress.config.ts',
54
+ '**/vite.config.js',
55
+ '**/vite.config.ts',
56
+ '**/vite.config.mts',
57
+ '**/vitest.config.ts',
58
+ '**/eslint.config.cjs',
59
+ '**/eslint.config.js',
60
+ '**/postcss.config.js',
61
+ '**/jest.config.js',
62
+ '**/jest.config.cjs',
63
+ '**/tailwind.config.js',
64
+ '**/tailwind.config.cjs',
65
+ '**/rollup.config.js',
66
+ '**/rollup.config.ts',
67
+ '**/config/**/*.js',
68
+ ],
69
+ languageOptions: {
70
+ globals: {
71
+ ...globals.node,
72
+ },
73
+ },
74
+ },
75
+ {
76
+ files: ['**/*.spec.js', '**/*.spec.ts'],
77
+ languageOptions: {
78
+ globals: {
79
+ // We configure vite with globals: true
80
+ global: true,
81
+ },
82
+ },
83
+ },
84
+ {
85
+ ignores: [
86
+ '**/node_modules/',
87
+ '**/dist/',
88
+ '**/typings/',
89
+ '**/coverage/',
90
+ '**/public/static/',
91
+ '**/*.css',
92
+ '**/*.svg',
93
+ '**/*.min.js',
94
+ ],
95
+ },
96
+ prettier,
97
+ ];
98
+
package/package.json CHANGED
@@ -6,39 +6,45 @@
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/Rebilly/rebilly.git"
8
8
  },
9
- "main": "index.js",
10
- "version": "4.9.2",
9
+ "main": "index.cjs",
10
+ "version": "4.10.1",
11
11
  "scripts": {
12
12
  "build": "echo 'Building ESLint config'"
13
13
  },
14
14
  "files": [
15
- "index.js",
16
- "typescript.js",
17
- "vue.js"
15
+ "index.cjs",
16
+ "typescript.cjs",
17
+ "vue.cjs"
18
18
  ],
19
19
  "publishConfig": {
20
20
  "access": "public"
21
21
  },
22
+ "exports": {
23
+ ".": "./index.cjs",
24
+ "./typescript": "./typescript.cjs",
25
+ "./vue": "./vue.cjs"
26
+ },
22
27
  "peerDependencies": {
23
- "@typescript-eslint/eslint-plugin": "^7.17.0",
24
- "@typescript-eslint/parser": "^7.14.1",
25
- "@vue/eslint-config-typescript": "^14.5.0",
26
- "eslint": "^8.57.1",
27
- "eslint-plugin-cypress": "^3.5.0",
28
+ "@eslint/js": "^9.39.2",
29
+ "eslint": "^9.39.2",
30
+ "eslint-config-prettier": "^10.1.8",
31
+ "eslint-plugin-cypress": "^5.21.0",
28
32
  "eslint-plugin-vitest": "^0.5.4",
29
- "eslint-plugin-vue": "^9.32.0",
30
- "vue-eslint-parser": "^10.1.1"
33
+ "eslint-plugin-vue": "^10.6.2",
34
+ "globals": "^17.0.0",
35
+ "typescript-eslint": "^8.52.0",
36
+ "vue-eslint-parser": "^10.2.0"
31
37
  },
32
38
  "devDependencies": {
33
- "@typescript-eslint/eslint-plugin": "^7.17.0",
34
- "@typescript-eslint/parser": "^7.14.1",
35
- "@vue/eslint-config-typescript": "^14.5.0",
36
- "eslint": "^8.57.1",
37
- "eslint-plugin-cypress": "^3.5.0",
39
+ "@eslint/js": "^9.39.2",
40
+ "eslint": "^9.39.2",
41
+ "eslint-config-prettier": "^10.1.8",
42
+ "eslint-plugin-cypress": "^5.2.0",
38
43
  "eslint-plugin-vitest": "^0.5.4",
39
- "eslint-plugin-vue": "^9.32.0",
40
- "prettier": "^3.1.0",
41
- "vue-eslint-parser": "^10.1.1"
44
+ "eslint-plugin-vue": "^10.6.2",
45
+ "globals": "^17.0.0",
46
+ "typescript-eslint": "^8.52.0",
47
+ "vue-eslint-parser": "^10.2.0"
42
48
  },
43
49
  "engines": {
44
50
  "node": ">=18.18"
package/typescript.cjs ADDED
@@ -0,0 +1,60 @@
1
+ const tseslint = require('typescript-eslint');
2
+ const prettier = require('eslint-config-prettier');
3
+ const baseConfig = require('./index.cjs');
4
+
5
+ /**
6
+ * ESLint flat config for TypeScript projects.
7
+ * Extends base config and adds TypeScript-specific rules.
8
+ */
9
+ module.exports = [
10
+ ...baseConfig,
11
+ // Register TypeScript plugin globally so rule names are recognized in eslint-disable comments
12
+ {
13
+ plugins: {
14
+ '@typescript-eslint': tseslint.plugin,
15
+ },
16
+ },
17
+ // Apply TypeScript recommended rules only to TypeScript files
18
+ ...tseslint.configs.recommended.map((config) => ({
19
+ ...config,
20
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
21
+ })),
22
+ {
23
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
24
+ languageOptions: {
25
+ parser: tseslint.parser,
26
+ parserOptions: {
27
+ ecmaVersion: 2022,
28
+ sourceType: 'module',
29
+ },
30
+ },
31
+ rules: {
32
+ // TypeScript handles these checks
33
+ 'no-undef': 'off',
34
+ 'no-unused-vars': 'off',
35
+ '@typescript-eslint/no-unused-vars': [
36
+ 'error',
37
+ {
38
+ argsIgnorePattern: '^_',
39
+ caughtErrors: 'none',
40
+ },
41
+ ],
42
+ '@typescript-eslint/ban-ts-comment': [
43
+ 'error',
44
+ {
45
+ 'ts-ignore': true,
46
+ 'ts-expect-error': 'allow-with-description',
47
+ 'ts-nocheck': 'allow-with-description',
48
+ },
49
+ ],
50
+ '@typescript-eslint/consistent-type-imports': 'error',
51
+ // Disable new rules in typescript-eslint v8 that weren't in the original config
52
+ '@typescript-eslint/no-empty-object-type': 'off',
53
+ '@typescript-eslint/no-unused-expressions': 'off',
54
+ // Disable prefer-const (new in eslint:recommended, not in original config)
55
+ 'prefer-const': 'off',
56
+ },
57
+ },
58
+ // Disable stylistic rules that conflict with Prettier (Prettier runs separately)
59
+ prettier,
60
+ ];
package/vue.cjs ADDED
@@ -0,0 +1,146 @@
1
+ const tseslint = require('typescript-eslint');
2
+ const vue = require('eslint-plugin-vue');
3
+ const vueParser = require('vue-eslint-parser');
4
+ const globals = require('globals');
5
+ const prettier = require('eslint-config-prettier');
6
+ const baseConfig = require('./index.cjs');
7
+
8
+ /**
9
+ * ESLint flat config for Vue 3 projects with TypeScript.
10
+ * Extends base config and adds Vue and TypeScript-specific rules.
11
+ */
12
+ module.exports = [
13
+ ...baseConfig,
14
+ // Register TypeScript plugin globally so rule names are recognized in eslint-disable comments
15
+ {
16
+ plugins: {
17
+ '@typescript-eslint': tseslint.plugin,
18
+ },
19
+ },
20
+ // Apply TypeScript recommended rules only to TypeScript and Vue files
21
+ ...tseslint.configs.recommended.map((config) => ({
22
+ ...config,
23
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts', '**/*.vue'],
24
+ })),
25
+ ...vue.configs['flat/recommended'],
26
+ {
27
+ files: ['**/*.vue'],
28
+ languageOptions: {
29
+ parser: vueParser,
30
+ parserOptions: {
31
+ parser: tseslint.parser,
32
+ ecmaVersion: 2022,
33
+ sourceType: 'module',
34
+ },
35
+ globals: {
36
+ ...globals.browser,
37
+ },
38
+ },
39
+ rules: {
40
+ // TypeScript handles this check
41
+ 'no-undef': 'off',
42
+ 'no-unused-vars': 'off',
43
+ '@typescript-eslint/no-unused-vars': [
44
+ 'error',
45
+ {
46
+ argsIgnorePattern: '^_',
47
+ caughtErrors: 'none',
48
+ },
49
+ ],
50
+ '@typescript-eslint/ban-ts-comment': [
51
+ 'error',
52
+ {
53
+ 'ts-ignore': true,
54
+ 'ts-expect-error': 'allow-with-description',
55
+ 'ts-nocheck': 'allow-with-description',
56
+ },
57
+ ],
58
+ '@typescript-eslint/consistent-type-imports': 'error',
59
+ // Disable new rules in typescript-eslint v8 that weren't in the original config
60
+ '@typescript-eslint/no-empty-object-type': 'off',
61
+ '@typescript-eslint/no-unused-expressions': 'off',
62
+ // Disable prefer-const (new in eslint:recommended, not in original config)
63
+ 'prefer-const': 'off',
64
+ },
65
+ },
66
+ {
67
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
68
+ languageOptions: {
69
+ parser: tseslint.parser,
70
+ parserOptions: {
71
+ ecmaVersion: 2022,
72
+ sourceType: 'module',
73
+ },
74
+ },
75
+ rules: {
76
+ // TypeScript handles these checks
77
+ 'no-undef': 'off',
78
+ 'no-unused-vars': 'off',
79
+ '@typescript-eslint/no-unused-vars': [
80
+ 'error',
81
+ {
82
+ argsIgnorePattern: '^_',
83
+ caughtErrors: 'none',
84
+ },
85
+ ],
86
+ '@typescript-eslint/ban-ts-comment': [
87
+ 'error',
88
+ {
89
+ 'ts-ignore': true,
90
+ 'ts-expect-error': 'allow-with-description',
91
+ 'ts-nocheck': 'allow-with-description',
92
+ },
93
+ ],
94
+ '@typescript-eslint/consistent-type-imports': 'error',
95
+ // Disable new rules in typescript-eslint v8 that weren't in the original config
96
+ '@typescript-eslint/no-empty-object-type': 'off',
97
+ '@typescript-eslint/no-unused-expressions': 'off',
98
+ // Disable prefer-const (new in eslint:recommended, not in original config)
99
+ 'prefer-const': 'off',
100
+ },
101
+ },
102
+ // Vue-specific rules
103
+ {
104
+ files: ['**/*.vue'],
105
+ rules: {
106
+ 'vue/require-v-for-key': 'error',
107
+ 'vue/require-prop-types': 'error',
108
+ 'vue/block-order': [
109
+ 'error',
110
+ {
111
+ order: [['script', 'template'], 'style'],
112
+ },
113
+ ],
114
+ 'vue/multi-word-component-names': 'off',
115
+ // Force lang="ts" in script tags
116
+ 'vue/block-lang': [
117
+ 'error',
118
+ {
119
+ script: {
120
+ lang: 'ts',
121
+ },
122
+ },
123
+ ],
124
+ 'vue/component-api-style': ['error', ['script-setup']],
125
+ 'vue/no-import-compiler-macros': ['error'],
126
+ },
127
+ },
128
+ // Test files can have multiple components
129
+ {
130
+ files: ['**/*.spec.js', '**/*.spec.ts'],
131
+ rules: {
132
+ 'vue/one-component-per-file': 'off',
133
+ },
134
+ },
135
+ // Browser globals for all Vue files
136
+ {
137
+ files: ['**/*.vue', '**/*.ts', '**/*.js'],
138
+ languageOptions: {
139
+ globals: {
140
+ ...globals.browser,
141
+ },
142
+ },
143
+ },
144
+ // Disable stylistic rules that conflict with Prettier (Prettier runs separately)
145
+ prettier,
146
+ ];
package/index.js DELETED
@@ -1,58 +0,0 @@
1
- const vitest = require('eslint-plugin-vitest');
2
-
3
- module.exports = {
4
- extends: ['eslint:recommended', 'plugin:cypress/recommended', 'prettier'],
5
- env: {
6
- es6: true,
7
- },
8
- parserOptions: {
9
- ecmaVersion: 'latest',
10
- },
11
- rules: {
12
- 'no-underscore-dangle': [
13
- 'error',
14
- { allow: ['_links', '_embedded', '_dev'] },
15
- ],
16
- 'prettier/prettier': 'error',
17
- 'no-lonely-if': 'error',
18
- 'no-implicit-coercion': 'error',
19
- },
20
- plugins: ['prettier', 'vitest'],
21
- globals: {
22
- // TODO: remove this and extend from vitest/recommended when there is time to fix the errors.
23
- ...vitest.environments.env.globals,
24
- },
25
- overrides: [
26
- {
27
- // Config files are usually executed in the node environment, regardless of the project type
28
- files: [
29
- '.eslintrc.cjs',
30
- '.eslintrc.js',
31
- 'babel.config.js',
32
- 'cypress.config.js',
33
- 'vite.config.js',
34
- ],
35
- env: {
36
- node: true,
37
- },
38
- },
39
- {
40
- files: ['*.spec.js', '*.spec.ts'],
41
- globals: {
42
- // We configure vite with globals: true, which adds this global variable
43
- // https://vitest.dev/config/#globals
44
- global: true,
45
- },
46
- },
47
- ],
48
- ignorePatterns: [
49
- 'node_modules/',
50
- 'dist/',
51
- 'typings/',
52
- 'coverage/',
53
- 'public/static/',
54
- '*.css',
55
- '*.svg',
56
- '*.min.js',
57
- ],
58
- };
package/typescript.js DELETED
@@ -1,34 +0,0 @@
1
- module.exports = {
2
- extends: ['plugin:@typescript-eslint/recommended', './index.js'],
3
- parser: '@typescript-eslint/parser',
4
- parserOptions: {
5
- parser: '@typescript-eslint/parser',
6
- ecmaVersion: 2022,
7
- sourceType: 'module',
8
- },
9
- plugins: ['@typescript-eslint'],
10
- rules: {
11
- 'no-undef': 'off',
12
- 'no-unused-vars': 'off',
13
- '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
14
- '@typescript-eslint/ban-ts-comment': [
15
- 'error',
16
- {
17
- 'ts-ignore': true,
18
- 'ts-expect-error': 'allow-with-description',
19
- 'ts-nocheck': 'allow-with-description',
20
- },
21
- ],
22
- '@typescript-eslint/consistent-type-imports': 'error',
23
- },
24
- overrides: [
25
- {
26
- files: ['*.ts'],
27
- rules: {
28
- // It is recommended to turn this rule off for typescript, as it does it's own checking:
29
- // https://typescript-eslint.io/linting/troubleshooting#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
30
- 'no-undef': 'off',
31
- },
32
- },
33
- ],
34
- };
package/vue.js DELETED
@@ -1,46 +0,0 @@
1
- module.exports = {
2
- env: {
3
- 'vue/setup-compiler-macros': true,
4
- browser: true,
5
- },
6
- extends: ['plugin:vue/vue3-recommended', './typescript.js'],
7
- parser: 'vue-eslint-parser',
8
- rules: {
9
- 'vue/require-v-for-key': 'error',
10
- 'vue/require-prop-types': 'error',
11
- 'vue/component-tags-order': [
12
- 'error',
13
- {
14
- order: ['script', 'template', 'style'],
15
- },
16
- ],
17
- 'vue/multi-word-component-names': 'off',
18
- // Force lang="ts" in script tags
19
- 'vue/block-lang': [
20
- 'error',
21
- {
22
- script: {
23
- lang: 'ts',
24
- },
25
- },
26
- ],
27
- 'vue/component-api-style': ['error', ['script-setup']],
28
- },
29
- overrides: [
30
- {
31
- files: ['*.vue'],
32
- rules: {
33
- // It is recommended to turn this rule off for typescript, as it does it's own checking:
34
- // https://typescript-eslint.io/linting/troubleshooting#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
35
- 'no-undef': 'off',
36
- },
37
- },
38
- {
39
- files: ['*.spec.js', '*.spec.ts'],
40
- rules: {
41
- // This can throw erroneously in test files, and doesn't apply
42
- 'vue/one-component-per-file': 'off',
43
- },
44
- },
45
- ],
46
- };