@tb-dev/eslint-config 1.4.11 → 1.5.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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Andrew Ferreira
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Andrew Ferreira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs CHANGED
@@ -9,6 +9,7 @@ var Glob;
9
9
  Glob["ALL"] = "**/*.?([cm])[jt]s?(x)";
10
10
  Glob["JAVASCRIPT"] = "**/*.?([cm])js?(x)";
11
11
  Glob["TYPESCRIPT"] = "**/*.?([cm])ts?(x)";
12
+ Glob["VITEST"] = "**/*.{test,spec}.[jt]s";
12
13
  Glob["VUE"] = "**/*.vue";
13
14
  })(Glob || (Glob = {}));
14
15
  var GlobIgnore;
@@ -132,7 +133,7 @@ function javascript(options) {
132
133
  'no-sequences': 'error',
133
134
  'no-shadow-restricted-names': 'error',
134
135
  'no-sparse-arrays': 'error',
135
- 'no-template-curly-in-string': 'off',
136
+ 'no-template-curly-in-string': 'error',
136
137
  'no-undef-init': 'error',
137
138
  'no-undefined': 'error',
138
139
  'no-unexpected-multiline': 'error',
@@ -588,6 +589,64 @@ async function unicorn(options) {
588
589
  };
589
590
  }
590
591
 
592
+ async function vitest(options) {
593
+ const { overrides, vitest: enabled } = options;
594
+ if (!enabled)
595
+ return {};
596
+ const plugin = await interopDefault(import('eslint-plugin-vitest'));
597
+ return {
598
+ plugins: {
599
+ vitest: plugin
600
+ },
601
+ files: [Glob.VITEST],
602
+ rules: {
603
+ 'vitest/consistent-test-it': ['error', { fn: 'it', withinDescribe: 'it' }],
604
+ 'vitest/expect-expect': [
605
+ 'error',
606
+ {
607
+ assertFunctionNames: ['expect']
608
+ }
609
+ ],
610
+ 'vitest/max-expects': ['error', { max: 5 }],
611
+ 'vitest/max-nested-describe': ['error', { max: 1 }],
612
+ 'vitest/no-alias-methods': 'error',
613
+ 'vitest/no-commented-out-tests': 'error',
614
+ 'vitest/no-conditional-expect': 'error',
615
+ 'vitest/no-conditional-in-test': 'error',
616
+ 'vitest/no-conditional-tests': 'error',
617
+ 'vitest/no-done-callback': 'error',
618
+ 'vitest/no-duplicate-hooks': 'error',
619
+ 'vitest/no-identical-title': 'error',
620
+ 'vitest/no-import-node-test': 'error',
621
+ 'vitest/no-standalone-expect': 'error',
622
+ 'vitest/no-test-return-statement': 'error',
623
+ 'vitest/prefer-called-exactly-once-with': 'error',
624
+ 'vitest/prefer-comparison-matcher': 'error',
625
+ 'vitest/prefer-each': 'error',
626
+ 'vitest/prefer-equality-matcher': 'error',
627
+ 'vitest/prefer-expect-resolves': 'error',
628
+ 'vitest/prefer-hooks-in-order': 'error',
629
+ 'vitest/prefer-hooks-on-top': 'error',
630
+ 'vitest/prefer-lowercase-title': 'error',
631
+ 'vitest/prefer-mock-promise-shorthand': 'error',
632
+ 'vitest/prefer-spy-on': 'error',
633
+ 'vitest/prefer-to-be-object': 'error',
634
+ 'vitest/prefer-to-contain': 'error',
635
+ 'vitest/prefer-to-have-length': 'error',
636
+ 'vitest/prefer-todo': 'error',
637
+ 'vitest/require-top-level-describe': [
638
+ 'error',
639
+ {
640
+ maxNumberOfTopLevelDescribes: 10
641
+ }
642
+ ],
643
+ 'vitest/valid-describe-callback': 'error',
644
+ 'vitest/valid-expect': 'error',
645
+ ...overrides?.vitest
646
+ }
647
+ };
648
+ }
649
+
591
650
  /* eslint-disable @typescript-eslint/no-explicit-any */
592
651
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
593
652
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
@@ -881,6 +940,7 @@ async function config(options) {
881
940
  ...(await vue(options)),
882
941
  perfectionist(options),
883
942
  unicorn(options),
943
+ vitest(options),
884
944
  prettier ? eslintConfigPrettier : {},
885
945
  {
886
946
  ignores: [...getIgnores(), ...(options.ignores ?? [])]
package/dist/index.d.ts CHANGED
@@ -1,44 +1 @@
1
- declare function config(options: ConfigOptions): Promise<Partial<ConfigObject>[]>;
2
- export default config;
3
-
4
- /** @see https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-objects */
5
- declare interface ConfigObject {
6
- files: string[];
7
- ignores?: Ignores['ignores'];
8
- languageOptions: {
9
- ecmaVersion?: 'latest';
10
- sourceType?: 'module';
11
- parser?: unknown;
12
- parserOptions?: Record<string, unknown>;
13
- globals?: Record<string, boolean | 'readonly' | 'writeable'>;
14
- };
15
- plugins?: Record<string, unknown>;
16
- processor?: unknown;
17
- rules: Rules;
18
- }
19
-
20
- declare interface ConfigOptions {
21
- prettier?: boolean;
22
- vue?: boolean;
23
- jsx?: boolean;
24
- /** `tsconfig.json` files for Typescript. */
25
- project: string[];
26
- ignores?: Ignores['ignores'];
27
- overrides?: {
28
- javascript?: Rules;
29
- typescript?: Rules;
30
- vue?: Rules;
31
- };
32
- }
33
-
34
- declare interface Ignores {
35
- ignores: string[];
36
- }
37
-
38
- declare type RuleOption = [Severity, string | Record<string, unknown>] | [Severity, string, Record<string, unknown>];
39
-
40
- declare type Rules = Record<string, Severity | RuleOption>;
41
-
42
- declare type Severity = 'error' | 'warn' | 'off' | 0 | 1;
43
-
44
1
  export { }
package/dist/index.mjs CHANGED
@@ -7,6 +7,7 @@ var Glob;
7
7
  Glob["ALL"] = "**/*.?([cm])[jt]s?(x)";
8
8
  Glob["JAVASCRIPT"] = "**/*.?([cm])js?(x)";
9
9
  Glob["TYPESCRIPT"] = "**/*.?([cm])ts?(x)";
10
+ Glob["VITEST"] = "**/*.{test,spec}.[jt]s";
10
11
  Glob["VUE"] = "**/*.vue";
11
12
  })(Glob || (Glob = {}));
12
13
  var GlobIgnore;
@@ -130,7 +131,7 @@ function javascript(options) {
130
131
  'no-sequences': 'error',
131
132
  'no-shadow-restricted-names': 'error',
132
133
  'no-sparse-arrays': 'error',
133
- 'no-template-curly-in-string': 'off',
134
+ 'no-template-curly-in-string': 'error',
134
135
  'no-undef-init': 'error',
135
136
  'no-undefined': 'error',
136
137
  'no-unexpected-multiline': 'error',
@@ -586,6 +587,64 @@ async function unicorn(options) {
586
587
  };
587
588
  }
588
589
 
590
+ async function vitest(options) {
591
+ const { overrides, vitest: enabled } = options;
592
+ if (!enabled)
593
+ return {};
594
+ const plugin = await interopDefault(import('eslint-plugin-vitest'));
595
+ return {
596
+ plugins: {
597
+ vitest: plugin
598
+ },
599
+ files: [Glob.VITEST],
600
+ rules: {
601
+ 'vitest/consistent-test-it': ['error', { fn: 'it', withinDescribe: 'it' }],
602
+ 'vitest/expect-expect': [
603
+ 'error',
604
+ {
605
+ assertFunctionNames: ['expect']
606
+ }
607
+ ],
608
+ 'vitest/max-expects': ['error', { max: 5 }],
609
+ 'vitest/max-nested-describe': ['error', { max: 1 }],
610
+ 'vitest/no-alias-methods': 'error',
611
+ 'vitest/no-commented-out-tests': 'error',
612
+ 'vitest/no-conditional-expect': 'error',
613
+ 'vitest/no-conditional-in-test': 'error',
614
+ 'vitest/no-conditional-tests': 'error',
615
+ 'vitest/no-done-callback': 'error',
616
+ 'vitest/no-duplicate-hooks': 'error',
617
+ 'vitest/no-identical-title': 'error',
618
+ 'vitest/no-import-node-test': 'error',
619
+ 'vitest/no-standalone-expect': 'error',
620
+ 'vitest/no-test-return-statement': 'error',
621
+ 'vitest/prefer-called-exactly-once-with': 'error',
622
+ 'vitest/prefer-comparison-matcher': 'error',
623
+ 'vitest/prefer-each': 'error',
624
+ 'vitest/prefer-equality-matcher': 'error',
625
+ 'vitest/prefer-expect-resolves': 'error',
626
+ 'vitest/prefer-hooks-in-order': 'error',
627
+ 'vitest/prefer-hooks-on-top': 'error',
628
+ 'vitest/prefer-lowercase-title': 'error',
629
+ 'vitest/prefer-mock-promise-shorthand': 'error',
630
+ 'vitest/prefer-spy-on': 'error',
631
+ 'vitest/prefer-to-be-object': 'error',
632
+ 'vitest/prefer-to-contain': 'error',
633
+ 'vitest/prefer-to-have-length': 'error',
634
+ 'vitest/prefer-todo': 'error',
635
+ 'vitest/require-top-level-describe': [
636
+ 'error',
637
+ {
638
+ maxNumberOfTopLevelDescribes: 10
639
+ }
640
+ ],
641
+ 'vitest/valid-describe-callback': 'error',
642
+ 'vitest/valid-expect': 'error',
643
+ ...overrides?.vitest
644
+ }
645
+ };
646
+ }
647
+
589
648
  /* eslint-disable @typescript-eslint/no-explicit-any */
590
649
  /* eslint-disable @typescript-eslint/no-unsafe-assignment */
591
650
  /* eslint-disable @typescript-eslint/no-unsafe-member-access */
@@ -879,6 +938,7 @@ async function config(options) {
879
938
  ...(await vue(options)),
880
939
  perfectionist(options),
881
940
  unicorn(options),
941
+ vitest(options),
882
942
  prettier ? eslintConfigPrettier : {},
883
943
  {
884
944
  ignores: [...getIgnores(), ...(options.ignores ?? [])]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/eslint-config",
3
- "version": "1.4.11",
3
+ "version": "1.5.0",
4
4
  "description": "ESLint config",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,12 +17,23 @@
17
17
  "lint-staged": {
18
18
  "*.{?(c|m)@(j|t)s,css,vue,md,json}": "prettier --write"
19
19
  },
20
+ "scripts": {
21
+ "build": "rollup --config rollup.config.js",
22
+ "deps": "pnpm exec taze -w -f -l",
23
+ "format": "pnpm exec prettier . --write",
24
+ "format-check": "pnpm exec prettier . --check",
25
+ "lint": "eslint . --config eslint.config.js --cache",
26
+ "prepare": "husky install",
27
+ "release": "miho -l publish",
28
+ "typecheck": "tsc --noEmit"
29
+ },
20
30
  "dependencies": {
21
31
  "@typescript-eslint/eslint-plugin": "^6.15.0",
22
32
  "@typescript-eslint/parser": "^6.15.0",
23
33
  "eslint-config-prettier": "^9.1.0",
24
34
  "eslint-plugin-perfectionist": "^2.5.0",
25
35
  "eslint-plugin-unicorn": "^49.0.0",
36
+ "eslint-plugin-vitest": "^0.3.18",
26
37
  "eslint-plugin-vue": "^9.19.2",
27
38
  "globals": "^13.24.0",
28
39
  "vue-eslint-parser": "^9.3.2"
@@ -33,6 +44,7 @@
33
44
  "@types/eslint-config-prettier": "^6.11.3",
34
45
  "@types/node": "^20.10.5",
35
46
  "eslint": "^8.56.0",
47
+ "execa": "^8.0.1",
36
48
  "husky": "^8.0.3",
37
49
  "lint-staged": "^15.2.0",
38
50
  "miho": "^2.2.3",
@@ -61,14 +73,5 @@
61
73
  "import": "./dist/index.mjs",
62
74
  "require": "./dist/index.cjs"
63
75
  }
64
- },
65
- "scripts": {
66
- "build": "rollup --config rollup.config.js",
67
- "deps": "pnpm exec taze -w -f -l",
68
- "format": "pnpm exec prettier . --write",
69
- "format-check": "pnpm exec prettier . --check",
70
- "lint": "eslint . --config eslint.config.js --cache",
71
- "release": "miho -l publish",
72
- "typecheck": "tsc --noEmit"
73
76
  }
74
- }
77
+ }