@html-validate/eslint-config-typescript 5.28.0 → 5.29.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 (2) hide show
  1. package/index.mjs +107 -15
  2. package/package.json +5 -6
package/index.mjs CHANGED
@@ -1,20 +1,112 @@
1
- import { fileURLToPath } from "node:url";
2
- import path from "node:path";
3
- import { FlatCompat } from "@eslint/eslintrc";
4
- import legacyConfig from "./legacy.cjs";
1
+ import { configs as tseConfig, parser as tseParser, plugin as tsePlugin } from "typescript-eslint";
2
+ import tsdocPlugin from "eslint-plugin-tsdoc";
3
+ import importPlugin from "eslint-plugin-import";
5
4
 
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
5
+ /**
6
+ * @typedef {import("eslint").Linter.Config} Config
7
+ */
8
8
 
9
- const compat = new FlatCompat({
10
- baseDirectory: __dirname,
11
- resolvePluginsRelativeTo: __dirname,
12
- });
13
-
14
- const migrated = compat.config(legacyConfig);
9
+ /**
10
+ * @param {Config} config
11
+ * @returns {Config}
12
+ */
13
+ function defineConfig(config) {
14
+ return config;
15
+ }
15
16
 
16
- for (const ruleset of migrated) {
17
- ruleset.files = ["**/*.ts"];
17
+ function flatten(result, it) {
18
+ return {
19
+ ...result,
20
+ ...it,
21
+ languageOptions: {
22
+ ...result.languageOptions,
23
+ ...it.languageOptions,
24
+ },
25
+ plugins: {
26
+ ...result.plugins,
27
+ ...it.plugins,
28
+ },
29
+ rules: {
30
+ ...result.rules,
31
+ ...it.rules,
32
+ },
33
+ };
18
34
  }
19
35
 
20
- export default migrated;
36
+ /** @type {Config} */
37
+ const strict = tseConfig.strict.reduce(flatten, {});
38
+
39
+ /** @type {Config} */
40
+ const stylistic = tseConfig.stylistic.reduce(flatten, {});
41
+
42
+ /** @type {Config} */
43
+ const importConfig = importPlugin.flatConfigs.typescript;
44
+
45
+ export default defineConfig({
46
+ languageOptions: {
47
+ parser: tseParser,
48
+ sourceType: "module",
49
+ },
50
+ plugins: {
51
+ "@typescript-eslint": tsePlugin,
52
+ tsdoc: tsdocPlugin,
53
+ },
54
+ settings: {
55
+ ...importConfig.settings,
56
+ },
57
+ rules: {
58
+ ...strict.rules,
59
+ ...stylistic.rules,
60
+ ...importConfig.rules,
61
+
62
+ /* typescript handles the return types */
63
+ "consistent-return": "off",
64
+
65
+ "tsdoc/syntax": "error",
66
+
67
+ /* prefer T[] for simple types, Array<T> for complex types (unions, etc) */
68
+ "@typescript-eslint/array-type": ["error", { default: "array-simple" }],
69
+
70
+ /* allow getters which returns a literal */
71
+ "@typescript-eslint/class-literal-property-style": "off",
72
+
73
+ "@typescript-eslint/explicit-function-return-type": [
74
+ "error",
75
+ {
76
+ allowExpressions: true,
77
+ },
78
+ ],
79
+ "@typescript-eslint/explicit-member-accessibility": "error",
80
+ "@typescript-eslint/no-inferrable-types": "off",
81
+
82
+ /* allow function(this: void, ...) */
83
+ "@typescript-eslint/no-invalid-void-type": [
84
+ "error",
85
+ {
86
+ allowAsThisParameter: true,
87
+ },
88
+ ],
89
+
90
+ /* allow constructs such as `unknown | null`, while `unknown` does override
91
+ * `null` it can still serve as a self-documenting type to signal that
92
+ * `null` has a special meaning. It also helps when the type is to be
93
+ * replaced with a better type later. */
94
+ "@typescript-eslint/no-redundant-type-constituents": "off",
95
+
96
+ "@typescript-eslint/no-unused-vars": [
97
+ "error",
98
+ {
99
+ ignoreRestSiblings: true,
100
+ argsIgnorePattern: "^_",
101
+ },
102
+ ],
103
+
104
+ /* allow overloading only if the parameters have different names */
105
+ "@typescript-eslint/unified-signatures": [
106
+ "error",
107
+ {
108
+ ignoreDifferentlyNamedParameters: true,
109
+ },
110
+ ],
111
+ },
112
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-validate/eslint-config-typescript",
3
- "version": "5.28.0",
3
+ "version": "5.29.0",
4
4
  "description": "Eslint sharable config used by the various HTML-validate packages",
5
5
  "keywords": [
6
6
  "eslint",
@@ -28,10 +28,9 @@
28
28
  "prepublishOnly": "release-prepublish --retain-scripts"
29
29
  },
30
30
  "dependencies": {
31
- "@eslint/eslintrc": "3.3.0",
32
- "@typescript-eslint/eslint-plugin": "8.26.0",
33
- "@typescript-eslint/parser": "8.26.0",
34
- "eslint-plugin-tsdoc": "0.4.0"
31
+ "eslint-plugin-import": "2.31.0",
32
+ "eslint-plugin-tsdoc": "0.4.0",
33
+ "typescript-eslint": "8.26.1"
35
34
  },
36
35
  "peerDependencies": {
37
36
  "eslint": "^8.0.0"
@@ -43,5 +42,5 @@
43
42
  "publishConfig": {
44
43
  "access": "public"
45
44
  },
46
- "gitHead": "943b446e6793777ceb880c87aed74551789b2c4a"
45
+ "gitHead": "ca95247b7c60f1ba1a30795bece5fa762670d917"
47
46
  }