@haltcase/style 8.0.0-canary.1 → 8.0.0-canary.11
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/dist/types/eslint/configs/internal/base.d.ts +35 -11
- package/dist/types/eslint/configs/internal/utils/typescript.d.ts +6 -0
- package/dist/types/eslint/configs/typescript.d.ts +2 -2
- package/eslint/configs/browser.js +3 -3
- package/eslint/configs/cjs.js +2 -2
- package/eslint/configs/internal/base.js +40 -10
- package/eslint/configs/internal/commonjs.js +2 -2
- package/eslint/configs/internal/es2015.js +2 -2
- package/eslint/configs/internal/simple-import-sort.js +2 -2
- package/eslint/configs/internal/tsdoc.js +2 -2
- package/eslint/configs/internal/unicorn.js +26 -2
- package/eslint/configs/internal/utils/typescript.js +53 -0
- package/eslint/configs/next.js +9 -5
- package/eslint/configs/node.js +3 -3
- package/eslint/configs/playwright-test.js +2 -2
- package/eslint/configs/react.js +14 -10
- package/eslint/configs/typescript.js +25 -12
- package/eslint/index.js +2 -2
- package/eslint/rules/react-x.js +7 -7
- package/eslint/rules/typescript/naming-convention.js +1 -1
- package/package.json +31 -25
- package/readme.md +96 -12
- package/typescript/tsconfig.next.json +2 -0
- package/typescript/tsconfig.node-ts.json +10 -0
- package/typescript/tsconfig.node.json +1 -1
- package/typescript/tsconfig.node20.json +2 -1
- package/typescript/tsconfig.node22.json +3 -2
- package/typescript/tsconfig.node24.json +17 -0
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} TypeScriptProjectServiceOptions
|
|
3
|
+
* @property {true} projectService Use the TypeScript ESLint [project service](https://typescript-eslint.io/packages/parser#projectservice).
|
|
4
|
+
* @property {string | string[] | undefined} [tsconfigPaths] Paths to tsconfig.json files for resolving and linting imports.
|
|
5
|
+
* This defaults to `<root>/tsconfig.json` or `<root>/jsconfig.json` and
|
|
6
|
+
* [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) are supported.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {ParserOptions["project"] | TypeScriptProjectServiceOptions} TypeScriptProjectOptions
|
|
10
|
+
*/
|
|
1
11
|
/**
|
|
2
12
|
* @typedef {Object} HaltcaseStyleOptions
|
|
3
13
|
* @property {boolean} [browser] Whether to include browser rules and globals.
|
|
@@ -5,13 +15,12 @@
|
|
|
5
15
|
* @property {boolean} [nextjs] Whether to include Next.js rules (implies `react`).
|
|
6
16
|
* @property {boolean} [node] Whether to include Node.js rules.
|
|
7
17
|
* @property {boolean} [react] Whether to include React rules.
|
|
8
|
-
* @property {
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* property {ProjectServiceOptions} [typescriptProjectServiceOptions = true] Custom TypeScript project service options for the `typescript-eslint` parser.
|
|
18
|
+
* @property {string[]} [typescriptComponentPaths] Additional paths to consider as TypeScript component files.
|
|
19
|
+
* @property {TypeScriptProjectOptions} [typescriptProject] Custom TypeScript project options for
|
|
20
|
+
* the `typescript-eslint` parser and `eslint-import-resolver-typescript`.
|
|
12
21
|
*/
|
|
13
22
|
/**
|
|
14
|
-
* @typedef {(options?: HaltcaseStyleOptions) => Awaited<import("
|
|
23
|
+
* @typedef {(options?: HaltcaseStyleOptions) => Awaited<import("eslint/config").Config[]>} HaltcaseStyleCreator
|
|
15
24
|
*/
|
|
16
25
|
/**
|
|
17
26
|
* Get the common ESLint config for Node and browsers.
|
|
@@ -19,6 +28,19 @@
|
|
|
19
28
|
* @type {HaltcaseStyleCreator}
|
|
20
29
|
*/
|
|
21
30
|
export const getEslintBaseConfig: HaltcaseStyleCreator;
|
|
31
|
+
export type TypeScriptProjectServiceOptions = {
|
|
32
|
+
/**
|
|
33
|
+
* Use the TypeScript ESLint [project service](https://typescript-eslint.io/packages/parser#projectservice).
|
|
34
|
+
*/
|
|
35
|
+
projectService: true;
|
|
36
|
+
/**
|
|
37
|
+
* Paths to tsconfig.json files for resolving and linting imports.
|
|
38
|
+
* This defaults to `<root>/tsconfig.json` or `<root>/jsconfig.json` and
|
|
39
|
+
* [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) are supported.
|
|
40
|
+
*/
|
|
41
|
+
tsconfigPaths?: string | string[] | undefined;
|
|
42
|
+
};
|
|
43
|
+
export type TypeScriptProjectOptions = ParserOptions["project"] | TypeScriptProjectServiceOptions;
|
|
22
44
|
export type HaltcaseStyleOptions = {
|
|
23
45
|
/**
|
|
24
46
|
* Whether to include browser rules and globals.
|
|
@@ -41,12 +63,14 @@ export type HaltcaseStyleOptions = {
|
|
|
41
63
|
*/
|
|
42
64
|
react?: boolean | undefined;
|
|
43
65
|
/**
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
66
|
+
* Additional paths to consider as TypeScript component files.
|
|
67
|
+
*/
|
|
68
|
+
typescriptComponentPaths?: string[] | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Custom TypeScript project options for
|
|
71
|
+
* the `typescript-eslint` parser and `eslint-import-resolver-typescript`.
|
|
48
72
|
*/
|
|
49
|
-
typescriptProject?:
|
|
73
|
+
typescriptProject?: TypeScriptProjectOptions;
|
|
50
74
|
};
|
|
51
|
-
export type HaltcaseStyleCreator = (options?: HaltcaseStyleOptions) => Awaited<import("
|
|
75
|
+
export type HaltcaseStyleCreator = (options?: HaltcaseStyleOptions) => Awaited<import("eslint/config").Config[]>;
|
|
52
76
|
import type { ParserOptions } from "@typescript-eslint/types";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function prepareTypeScriptProjectConfig(projectInput: import("../base.js").TypeScriptProjectOptions): TypeScriptProjectConfig;
|
|
2
|
+
export type TypeScriptProjectConfig = {
|
|
3
|
+
parserOptions: import("@typescript-eslint/types").ParserOptions;
|
|
4
|
+
resolverOptions: TypeScriptResolverOptions;
|
|
5
|
+
};
|
|
6
|
+
import type { TypeScriptResolverOptions } from "eslint-import-resolver-typescript";
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const getEslintTypescriptConfig: import("./internal/base.js").HaltcaseStyleCreator;
|
|
5
5
|
/**
|
|
6
|
-
* @type {(options?: import("./internal/base.js").HaltcaseStyleOptions & {internal?: boolean}) => Awaited<import("
|
|
6
|
+
* @type {(options?: import("./internal/base.js").HaltcaseStyleOptions & {internal?: boolean}) => Awaited<import("eslint/config").Config[]>}
|
|
7
7
|
*/
|
|
8
8
|
export const getEslintTypescriptConfigInternal: (options?: import("./internal/base.js").HaltcaseStyleOptions & {
|
|
9
9
|
internal?: boolean;
|
|
10
|
-
}) => Awaited<import("
|
|
10
|
+
}) => Awaited<import("eslint/config").Config[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
import globals from "globals";
|
|
2
|
-
import { config } from "typescript-eslint";
|
|
3
3
|
|
|
4
4
|
import { getEslintBaseConfig } from "./internal/base.js";
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import { getEslintBaseConfig } from "./internal/base.js";
|
|
|
7
7
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
8
8
|
*/
|
|
9
9
|
export const getEslintBrowserConfig = (options = {}) =>
|
|
10
|
-
|
|
10
|
+
defineConfig(
|
|
11
11
|
...getEslintBaseConfig(options),
|
|
12
12
|
...getEslintBrowserConfigInternal(options)
|
|
13
13
|
);
|
|
@@ -16,7 +16,7 @@ export const getEslintBrowserConfig = (options = {}) =>
|
|
|
16
16
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
17
17
|
*/
|
|
18
18
|
export const getEslintBrowserConfigInternal = (_options = {}) =>
|
|
19
|
-
|
|
19
|
+
defineConfig({
|
|
20
20
|
name: "Browser",
|
|
21
21
|
|
|
22
22
|
languageOptions: {
|
package/eslint/configs/cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
2
|
|
|
3
3
|
import { getEslintBaseConfig } from "./internal/base.js";
|
|
4
4
|
import { getEslintCommonJsConfigInternal } from "./internal/commonjs.js";
|
|
@@ -7,7 +7,7 @@ import { getEslintCommonJsConfigInternal } from "./internal/commonjs.js";
|
|
|
7
7
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
8
8
|
*/
|
|
9
9
|
export const getEslintCommonJsConfig = (options) =>
|
|
10
|
-
|
|
10
|
+
defineConfig(
|
|
11
11
|
...getEslintBaseConfig(options),
|
|
12
12
|
...getEslintCommonJsConfigInternal(options)
|
|
13
13
|
);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @import { ParserOptions } from "@typescript-eslint/types"
|
|
2
|
+
* @import { type ParserOptions } from "@typescript-eslint/types"
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import babelParser from "@babel/eslint-parser";
|
|
6
6
|
import eslint from "@eslint/js";
|
|
7
7
|
import eslintPluginEslintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
8
|
+
import { defineConfig } from "eslint/config";
|
|
8
9
|
import eslintConfigPrettier from "eslint-config-prettier";
|
|
10
|
+
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
9
11
|
import * as eslintPluginImportX from "eslint-plugin-import-x";
|
|
10
12
|
import eslintRegexp from "eslint-plugin-regexp";
|
|
11
|
-
import { config } from "typescript-eslint";
|
|
12
13
|
|
|
13
14
|
import {
|
|
14
15
|
allSupportedFiles,
|
|
@@ -27,6 +28,19 @@ import { getEslintCommonJsConfigInternal } from "./commonjs.js";
|
|
|
27
28
|
import { eslintEs2015Config } from "./es2015.js";
|
|
28
29
|
import { eslintSimpleImportSortConfig } from "./simple-import-sort.js";
|
|
29
30
|
import { eslintUnicornConfig } from "./unicorn.js";
|
|
31
|
+
import { prepareTypeScriptProjectConfig } from "./utils/typescript.js";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {Object} TypeScriptProjectServiceOptions
|
|
35
|
+
* @property {true} projectService Use the TypeScript ESLint [project service](https://typescript-eslint.io/packages/parser#projectservice).
|
|
36
|
+
* @property {string | string[] | undefined} [tsconfigPaths] Paths to tsconfig.json files for resolving and linting imports.
|
|
37
|
+
* This defaults to `<root>/tsconfig.json` or `<root>/jsconfig.json` and
|
|
38
|
+
* [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) are supported.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {ParserOptions["project"] | TypeScriptProjectServiceOptions} TypeScriptProjectOptions
|
|
43
|
+
*/
|
|
30
44
|
|
|
31
45
|
/**
|
|
32
46
|
* @typedef {Object} HaltcaseStyleOptions
|
|
@@ -35,14 +49,19 @@ import { eslintUnicornConfig } from "./unicorn.js";
|
|
|
35
49
|
* @property {boolean} [nextjs] Whether to include Next.js rules (implies `react`).
|
|
36
50
|
* @property {boolean} [node] Whether to include Node.js rules.
|
|
37
51
|
* @property {boolean} [react] Whether to include React rules.
|
|
38
|
-
* @property {
|
|
52
|
+
* @property {string[]} [typescriptComponentPaths] Additional paths to consider as TypeScript component files.
|
|
53
|
+
* @property {TypeScriptProjectOptions} [typescriptProject] Custom TypeScript project options for
|
|
54
|
+
* the `typescript-eslint` parser and `eslint-import-resolver-typescript`.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/*
|
|
39
58
|
* // use when VS Code supports `projectService`
|
|
40
59
|
* // https://github.com/microsoft/vscode-eslint/issues/1911
|
|
41
60
|
* property {ProjectServiceOptions} [typescriptProjectServiceOptions = true] Custom TypeScript project service options for the `typescript-eslint` parser.
|
|
42
61
|
*/
|
|
43
62
|
|
|
44
63
|
/**
|
|
45
|
-
* @typedef {(options?: HaltcaseStyleOptions) => Awaited<import("
|
|
64
|
+
* @typedef {(options?: HaltcaseStyleOptions) => Awaited<import("eslint/config").Config[]>} HaltcaseStyleCreator
|
|
46
65
|
*/
|
|
47
66
|
|
|
48
67
|
/**
|
|
@@ -50,11 +69,18 @@ import { eslintUnicornConfig } from "./unicorn.js";
|
|
|
50
69
|
*
|
|
51
70
|
* @type {HaltcaseStyleCreator}
|
|
52
71
|
*/
|
|
53
|
-
export const getEslintBaseConfig = (options = {}) =>
|
|
54
|
-
|
|
72
|
+
export const getEslintBaseConfig = (options = {}) => {
|
|
73
|
+
const { resolverOptions } = prepareTypeScriptProjectConfig(
|
|
74
|
+
options.typescriptProject
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return defineConfig(
|
|
55
78
|
{
|
|
56
79
|
name: "import-x/recommended",
|
|
57
80
|
plugins: {
|
|
81
|
+
// @ts-expect-error
|
|
82
|
+
// https://github.com/un-ts/eslint-plugin-import-x/issues/421
|
|
83
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/11543
|
|
58
84
|
"import-x": eslintPluginImportX
|
|
59
85
|
},
|
|
60
86
|
rules: {
|
|
@@ -64,10 +90,13 @@ export const getEslintBaseConfig = (options = {}) =>
|
|
|
64
90
|
"import-x/parsers": {
|
|
65
91
|
"@typescript-eslint/parser": [".ts"]
|
|
66
92
|
},
|
|
67
|
-
"import-x/resolver":
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
"import-x/resolver-next": [
|
|
94
|
+
createTypeScriptImportResolver({
|
|
95
|
+
...resolverOptions
|
|
96
|
+
}),
|
|
97
|
+
|
|
98
|
+
eslintPluginImportX.createNodeResolver()
|
|
99
|
+
]
|
|
71
100
|
}
|
|
72
101
|
},
|
|
73
102
|
|
|
@@ -176,3 +205,4 @@ export const getEslintBaseConfig = (options = {}) =>
|
|
|
176
205
|
|
|
177
206
|
...getEslintCommonJsConfigInternal(options)
|
|
178
207
|
);
|
|
208
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
2
|
|
|
3
3
|
import { commonJsFiles, commonJsOnlyFiles } from "../../constants.js";
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import { commonJsFiles, commonJsOnlyFiles } from "../../constants.js";
|
|
|
6
6
|
* @type {import("./base.js").HaltcaseStyleCreator}
|
|
7
7
|
*/
|
|
8
8
|
export const getEslintCommonJsConfigInternal = (options = {}) =>
|
|
9
|
-
|
|
9
|
+
defineConfig({
|
|
10
10
|
name: "@haltcase/internal/CommonJS files",
|
|
11
11
|
|
|
12
12
|
files: options.commonjs ? commonJsFiles : commonJsOnlyFiles,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @type {ReturnType<import("./base.js").HaltcaseStyleCreator>}
|
|
5
5
|
*/
|
|
6
|
-
export const eslintEs2015Config =
|
|
6
|
+
export const eslintEs2015Config = defineConfig({
|
|
7
7
|
name: "@haltcase/internal/ES2015",
|
|
8
8
|
|
|
9
9
|
rules: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
|
|
2
|
-
import { config } from "typescript-eslint";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @type {ReturnType<import("./base.js").HaltcaseStyleCreator>}
|
|
6
6
|
*/
|
|
7
|
-
export const eslintSimpleImportSortConfig =
|
|
7
|
+
export const eslintSimpleImportSortConfig = defineConfig({
|
|
8
8
|
name: "@haltcase/internal/Import & export sorting",
|
|
9
9
|
|
|
10
10
|
plugins: {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
import eslintPluginTsdoc from "eslint-plugin-tsdoc";
|
|
2
|
-
import { config } from "typescript-eslint";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @type {ReturnType<import("./base.js").HaltcaseStyleCreator>}
|
|
6
6
|
*/
|
|
7
|
-
export const eslintTsdocConfig =
|
|
7
|
+
export const eslintTsdocConfig = defineConfig({
|
|
8
8
|
name: "@haltcase/internal/TSDoc comments",
|
|
9
9
|
plugins: {
|
|
10
10
|
tsdoc: eslintPluginTsdoc
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
import eslintPluginUnicorn from "eslint-plugin-unicorn";
|
|
2
|
-
import { config } from "typescript-eslint";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @type {ReturnType<import("./base.js").HaltcaseStyleCreator>}
|
|
6
6
|
*/
|
|
7
|
-
export const eslintUnicornConfig =
|
|
7
|
+
export const eslintUnicornConfig = defineConfig({
|
|
8
8
|
name: "@haltcase/internal/Unicorn",
|
|
9
9
|
|
|
10
10
|
plugins: {
|
|
@@ -119,6 +119,12 @@ export const eslintUnicornConfig = config({
|
|
|
119
119
|
* 🚫 Not fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reduce.md
|
|
120
120
|
*/
|
|
121
121
|
"unicorn/no-array-reduce": "off",
|
|
122
|
+
/**
|
|
123
|
+
* Prefer `Array#toReversed()` over `Array#reverse()`.
|
|
124
|
+
*
|
|
125
|
+
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reverse.md
|
|
126
|
+
*/
|
|
127
|
+
"unicorn/no-array-reverse": "error",
|
|
122
128
|
/**
|
|
123
129
|
* Disallow member access from await expression.
|
|
124
130
|
*
|
|
@@ -289,6 +295,12 @@ export const eslintUnicornConfig = config({
|
|
|
289
295
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-unused-properties.md
|
|
290
296
|
*/
|
|
291
297
|
"unicorn/no-unused-properties": "error",
|
|
298
|
+
/**
|
|
299
|
+
* Disallow unnecessary `Error.captureStackTrace(…)`.
|
|
300
|
+
*
|
|
301
|
+
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-error-capture-stack-trace.md
|
|
302
|
+
*/
|
|
303
|
+
"unicorn/no-useless-error-capture-stack-trace": "error",
|
|
292
304
|
/**
|
|
293
305
|
* Disallow useless fallback when spreading in object literals.
|
|
294
306
|
*
|
|
@@ -391,6 +403,12 @@ export const eslintUnicornConfig = config({
|
|
|
391
403
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-blob-reading-methods.md
|
|
392
404
|
*/
|
|
393
405
|
"unicorn/prefer-blob-reading-methods": "error",
|
|
406
|
+
/**
|
|
407
|
+
* Prefer class field declarations over `this` assignments in constructors.
|
|
408
|
+
*
|
|
409
|
+
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-class-fields.md
|
|
410
|
+
*/
|
|
411
|
+
"unicorn/prefer-class-fields": "error",
|
|
394
412
|
/**
|
|
395
413
|
* Prefer `String#codePointAt(…)` over `String#charCodeAt(…)` and `String.fromCodePoint(…)` over `String.fromCharCode(…)`.
|
|
396
414
|
*
|
|
@@ -677,6 +695,12 @@ export const eslintUnicornConfig = config({
|
|
|
677
695
|
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-array-join-separator.md
|
|
678
696
|
*/
|
|
679
697
|
"unicorn/require-array-join-separator": "error",
|
|
698
|
+
/**
|
|
699
|
+
* Require non-empty specifier list in import and export statements.
|
|
700
|
+
*
|
|
701
|
+
* 🔧 Fixable - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-module-specifiers.md
|
|
702
|
+
*/
|
|
703
|
+
"unicorn/require-module-specifiers": "error",
|
|
680
704
|
/**
|
|
681
705
|
* Enforce using the digits argument with `Number#toFixed()`.
|
|
682
706
|
*
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import { type TypeScriptResolverOptions } from "eslint-import-resolver-typescript"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} TypeScriptProjectConfig
|
|
7
|
+
* @property {import("@typescript-eslint/types").ParserOptions} parserOptions
|
|
8
|
+
* @property {TypeScriptResolverOptions} resolverOptions
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {import("../base.js").TypeScriptProjectOptions} projectInput
|
|
13
|
+
* @returns {TypeScriptProjectConfig}
|
|
14
|
+
*/
|
|
15
|
+
export const prepareTypeScriptProjectConfig = (projectInput) => {
|
|
16
|
+
// eslint-disable-next-line unicorn/prefer-default-parameters -- default parameters don't handle `null`
|
|
17
|
+
const project = projectInput ?? true;
|
|
18
|
+
|
|
19
|
+
if (typeof project === "string" || Array.isArray(project)) {
|
|
20
|
+
return {
|
|
21
|
+
parserOptions: {
|
|
22
|
+
project
|
|
23
|
+
},
|
|
24
|
+
resolverOptions: {
|
|
25
|
+
project
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (typeof project === "object" && project !== null) {
|
|
31
|
+
return {
|
|
32
|
+
parserOptions: {
|
|
33
|
+
projectService: project.projectService
|
|
34
|
+
},
|
|
35
|
+
resolverOptions: {
|
|
36
|
+
project: project.tsconfigPaths
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (typeof project !== "boolean") {
|
|
42
|
+
throw new TypeError(
|
|
43
|
+
"Invariant violation: expected project to be a boolean"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
parserOptions: {
|
|
49
|
+
project
|
|
50
|
+
},
|
|
51
|
+
resolverOptions: {}
|
|
52
|
+
};
|
|
53
|
+
};
|
package/eslint/configs/next.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pluginNextjs from "@next/eslint-plugin-next";
|
|
2
|
-
import {
|
|
2
|
+
import { defineConfig } from "eslint/config";
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
allSupportedFiles,
|
|
@@ -11,11 +11,15 @@ import { getEslintBaseConfig } from "./internal/base.js";
|
|
|
11
11
|
import { getEslintNodeConfigInternal } from "./node.js";
|
|
12
12
|
import { getEslintReactConfigInternal } from "./react.js";
|
|
13
13
|
|
|
14
|
+
// Remove this when `@next/eslint-plugin-next` is ESM and typed properly
|
|
15
|
+
// eslint-disable-next-line import-x/no-named-as-default-member
|
|
16
|
+
const nextJsConfigs = pluginNextjs.configs;
|
|
17
|
+
|
|
14
18
|
/**
|
|
15
19
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
16
20
|
*/
|
|
17
21
|
export const getEslintNextConfig = (options = {}) =>
|
|
18
|
-
|
|
22
|
+
defineConfig(
|
|
19
23
|
...getEslintBaseConfig(options),
|
|
20
24
|
...getEslintNodeConfigInternal(options),
|
|
21
25
|
...getEslintNextConfigInternal(options)
|
|
@@ -25,7 +29,7 @@ export const getEslintNextConfig = (options = {}) =>
|
|
|
25
29
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
26
30
|
*/
|
|
27
31
|
export const getEslintNextConfigInternal = (options = {}) =>
|
|
28
|
-
|
|
32
|
+
defineConfig(
|
|
29
33
|
...getEslintReactConfigInternal(options),
|
|
30
34
|
{
|
|
31
35
|
name: "@haltcase/nextjs",
|
|
@@ -35,8 +39,8 @@ export const getEslintNextConfigInternal = (options = {}) =>
|
|
|
35
39
|
"@next/next": pluginNextjs
|
|
36
40
|
},
|
|
37
41
|
rules: {
|
|
38
|
-
...
|
|
39
|
-
...
|
|
42
|
+
...nextJsConfigs.recommended.rules,
|
|
43
|
+
...nextJsConfigs["core-web-vitals"].rules
|
|
40
44
|
}
|
|
41
45
|
},
|
|
42
46
|
{
|
package/eslint/configs/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
import globals from "globals";
|
|
2
|
-
import { config } from "typescript-eslint";
|
|
3
3
|
|
|
4
4
|
import { getEslintBaseConfig } from "./internal/base.js";
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ import { getEslintBaseConfig } from "./internal/base.js";
|
|
|
7
7
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
8
8
|
*/
|
|
9
9
|
export const getEslintNodeConfig = (options = {}) =>
|
|
10
|
-
|
|
10
|
+
defineConfig(
|
|
11
11
|
...getEslintNodeConfigInternal(options),
|
|
12
12
|
...getEslintBaseConfig(options)
|
|
13
13
|
);
|
|
@@ -16,7 +16,7 @@ export const getEslintNodeConfig = (options = {}) =>
|
|
|
16
16
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
17
17
|
*/
|
|
18
18
|
export const getEslintNodeConfigInternal = (_options = {}) =>
|
|
19
|
-
|
|
19
|
+
defineConfig({
|
|
20
20
|
name: "@haltcase/Node.js",
|
|
21
21
|
|
|
22
22
|
languageOptions: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
import eslintPluginPlaywright from "eslint-plugin-playwright";
|
|
2
|
-
import { config } from "typescript-eslint";
|
|
3
3
|
|
|
4
4
|
import { playwrightTestRules } from "../rules/playwright-test.js";
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ const playwrightRecommendedConfig =
|
|
|
10
10
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
11
11
|
*/
|
|
12
12
|
export const getEslintPlaywrightTestConfig = (_options = {}) =>
|
|
13
|
-
|
|
13
|
+
defineConfig({
|
|
14
14
|
...playwrightRecommendedConfig,
|
|
15
15
|
|
|
16
16
|
name: "Playwright tests",
|
package/eslint/configs/react.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import eslintPluginReact from "@eslint-react/eslint-plugin";
|
|
2
2
|
import eslintStylisticJsx from "@stylistic/eslint-plugin-jsx";
|
|
3
|
+
import { defineConfig } from "eslint/config";
|
|
3
4
|
import * as eslintPluginImportX from "eslint-plugin-import-x";
|
|
4
5
|
import eslintPluginJsxA11y from "eslint-plugin-jsx-a11y";
|
|
5
6
|
import eslintPluginReactOriginal from "eslint-plugin-react";
|
|
6
|
-
// eslint-disable-next-line import-x/default
|
|
7
7
|
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
|
|
8
|
-
import
|
|
8
|
+
import eslintPluginYouMightNotNeedAnEffect from "eslint-plugin-react-you-might-not-need-an-effect";
|
|
9
9
|
|
|
10
10
|
import { jsxFiles, typescriptJsxFiles } from "../constants.js";
|
|
11
11
|
import { jsxA11yRules } from "../rules/jsx-a11y.js";
|
|
@@ -18,7 +18,7 @@ import { getEslintBaseConfig } from "./internal/base.js";
|
|
|
18
18
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
19
19
|
*/
|
|
20
20
|
export const getEslintReactConfig = (options) =>
|
|
21
|
-
|
|
21
|
+
defineConfig(
|
|
22
22
|
...getEslintBaseConfig(options),
|
|
23
23
|
...getEslintReactConfigInternal(options)
|
|
24
24
|
);
|
|
@@ -27,7 +27,7 @@ export const getEslintReactConfig = (options) =>
|
|
|
27
27
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
28
28
|
*/
|
|
29
29
|
export const getEslintReactConfigInternal = (_options = {}) =>
|
|
30
|
-
|
|
30
|
+
defineConfig(
|
|
31
31
|
{
|
|
32
32
|
name: "@haltcase/react",
|
|
33
33
|
|
|
@@ -56,12 +56,12 @@ export const getEslintReactConfigInternal = (_options = {}) =>
|
|
|
56
56
|
|
|
57
57
|
{
|
|
58
58
|
name: "@haltcase/react/hooks",
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
...eslintPluginReactHooks.configs.flat.recommended
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
{
|
|
63
|
+
name: "@haltcase/react/you-might-not-need-an-effect",
|
|
64
|
+
...eslintPluginYouMightNotNeedAnEffect.configs.recommended
|
|
65
65
|
},
|
|
66
66
|
|
|
67
67
|
{
|
|
@@ -69,6 +69,10 @@ export const getEslintReactConfigInternal = (_options = {}) =>
|
|
|
69
69
|
...eslintPluginJsxA11y.flatConfigs.recommended
|
|
70
70
|
},
|
|
71
71
|
|
|
72
|
+
// @ts-expect-error this error is due to differences in type
|
|
73
|
+
// definitions between typescript-eslint's deprecated `config`
|
|
74
|
+
// and ESLint's `defineConfig`, but should work fine at runtime
|
|
75
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/10935#issuecomment-2852410510
|
|
72
76
|
{
|
|
73
77
|
name: "@haltcase/react/import-x",
|
|
74
78
|
...eslintPluginImportX.flatConfigs.react,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
1
2
|
import eslintConfigPrettier from "eslint-config-prettier";
|
|
3
|
+
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
2
4
|
import * as eslintPluginImportX from "eslint-plugin-import-x";
|
|
3
|
-
import {
|
|
5
|
+
import { configs, parser, plugin } from "typescript-eslint";
|
|
4
6
|
|
|
5
7
|
import { typescriptFiles, typescriptJsxFiles } from "../constants.js";
|
|
6
8
|
import { typescriptExtensionRules } from "../rules/typescript/extension.js";
|
|
@@ -8,6 +10,7 @@ import { typescriptImportRules } from "../rules/typescript/import.js";
|
|
|
8
10
|
import { typescriptBaseRules } from "../rules/typescript/index.js";
|
|
9
11
|
import { getTypescriptNamingConventionRule } from "../rules/typescript/naming-convention.js";
|
|
10
12
|
import { eslintTsdocConfig } from "./internal/tsdoc.js";
|
|
13
|
+
import { prepareTypeScriptProjectConfig } from "./internal/utils/typescript.js";
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
@@ -16,10 +19,14 @@ export const getEslintTypescriptConfig = (options = {}) =>
|
|
|
16
19
|
getEslintTypescriptConfigInternal(options);
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
|
-
* @type {(options?: import("./internal/base.js").HaltcaseStyleOptions & {internal?: boolean}) => Awaited<import("
|
|
22
|
+
* @type {(options?: import("./internal/base.js").HaltcaseStyleOptions & {internal?: boolean}) => Awaited<import("eslint/config").Config[]>}
|
|
20
23
|
*/
|
|
21
24
|
export const getEslintTypescriptConfigInternal = (options = {}) => {
|
|
22
|
-
|
|
25
|
+
const { parserOptions, resolverOptions } = prepareTypeScriptProjectConfig(
|
|
26
|
+
options.typescriptProject
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
/** @type {import("eslint/config").Config["languageOptions"]} */
|
|
23
30
|
const languageOptions = {
|
|
24
31
|
parser,
|
|
25
32
|
parserOptions: {
|
|
@@ -29,19 +36,20 @@ export const getEslintTypescriptConfigInternal = (options = {}) => {
|
|
|
29
36
|
},
|
|
30
37
|
// https://github.com/typescript-eslint/typescript-eslint/issues/3788#issuecomment-905094436
|
|
31
38
|
jsxPragma: null,
|
|
32
|
-
|
|
33
|
-
// use `projectService` when VS Code supports it properly
|
|
34
|
-
// https://github.com/microsoft/vscode-eslint/issues/1911
|
|
35
|
-
// projectService: options.typescriptProjectServiceOptions ?? true
|
|
39
|
+
...parserOptions
|
|
36
40
|
}
|
|
37
41
|
};
|
|
38
42
|
|
|
39
|
-
return
|
|
43
|
+
return defineConfig(
|
|
40
44
|
{
|
|
41
45
|
name: "@haltcase/internal/TypeScript files",
|
|
42
46
|
|
|
43
47
|
files: typescriptFiles,
|
|
44
48
|
|
|
49
|
+
// @ts-expect-error this error is due to differences in type
|
|
50
|
+
// definitions between typescript-eslint's deprecated `config`
|
|
51
|
+
// and ESLint's `defineConfig`, but should work fine at runtime
|
|
52
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/10935#issuecomment-2852410510
|
|
45
53
|
extends: [
|
|
46
54
|
...configs.recommendedTypeChecked,
|
|
47
55
|
...configs.strictTypeChecked,
|
|
@@ -72,9 +80,11 @@ export const getEslintTypescriptConfigInternal = (options = {}) => {
|
|
|
72
80
|
},
|
|
73
81
|
|
|
74
82
|
settings: {
|
|
75
|
-
"import-x/resolver":
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
"import-x/resolver-next": [
|
|
84
|
+
createTypeScriptImportResolver({
|
|
85
|
+
...resolverOptions
|
|
86
|
+
})
|
|
87
|
+
]
|
|
78
88
|
}
|
|
79
89
|
},
|
|
80
90
|
{
|
|
@@ -100,7 +110,10 @@ export const getEslintTypescriptConfigInternal = (options = {}) => {
|
|
|
100
110
|
// to create a customized instance of a UI component
|
|
101
111
|
name: "@haltcase/internal/TypeScript component files",
|
|
102
112
|
|
|
103
|
-
files: [
|
|
113
|
+
files: [
|
|
114
|
+
"**/components/**/*.ts",
|
|
115
|
+
...(options.typescriptComponentPaths ?? [])
|
|
116
|
+
],
|
|
104
117
|
languageOptions,
|
|
105
118
|
|
|
106
119
|
plugins: {
|
package/eslint/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
2
|
|
|
3
3
|
import { getEslintBrowserConfigInternal } from "./configs/browser.js";
|
|
4
4
|
import { getEslintBaseConfig } from "./configs/internal/base.js";
|
|
@@ -10,7 +10,7 @@ import { getEslintReactConfigInternal } from "./configs/react.js";
|
|
|
10
10
|
* @type {import("./configs/internal/base.js").HaltcaseStyleCreator}
|
|
11
11
|
*/
|
|
12
12
|
export const getEslintConfig = (options = {}) =>
|
|
13
|
-
|
|
13
|
+
defineConfig(
|
|
14
14
|
...getEslintBaseConfig(options),
|
|
15
15
|
...(options.browser ? getEslintBrowserConfigInternal(options) : []),
|
|
16
16
|
...(options.node ? getEslintNodeConfigInternal(options) : []),
|
package/eslint/rules/react-x.js
CHANGED
|
@@ -37,23 +37,23 @@ export const reactXRules = {
|
|
|
37
37
|
/**
|
|
38
38
|
* Enforces using shorthand syntax for boolean attributes.
|
|
39
39
|
*
|
|
40
|
-
* 🔧 Fixable - https://eslint-react.xyz/docs/rules/
|
|
40
|
+
* 🔧 Fixable - https://eslint-react.xyz/docs/rules/jsx-shorthand-boolean
|
|
41
41
|
*/
|
|
42
|
-
"@eslint-react/
|
|
42
|
+
"@eslint-react/jsx-shorthand-boolean": "error",
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Enforces using shorthand syntax for fragments.
|
|
46
46
|
*
|
|
47
|
-
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/
|
|
47
|
+
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/jsx-shorthand-fragment
|
|
48
48
|
*/
|
|
49
|
-
"@eslint-react/
|
|
49
|
+
"@eslint-react/jsx-shorthand-fragment": "error",
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Enforces function calls made inside `useState` to be wrapped in an initializer function.
|
|
53
53
|
*
|
|
54
54
|
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/hooks-extra-prefer-use-state-lazy-initialization
|
|
55
55
|
*/
|
|
56
|
-
"@eslint-react/
|
|
56
|
+
"@eslint-react/prefer-use-state-lazy-initialization": "error",
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Enforces naming conventions for components.
|
|
@@ -70,7 +70,7 @@ export const reactXRules = {
|
|
|
70
70
|
"@eslint-react/naming-convention/filename-extension": "warn",
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Enforces destructuring and symmetric naming of useState hook value and setter
|
|
73
|
+
* Enforces destructuring and symmetric naming of `useState` hook value and setter.
|
|
74
74
|
*
|
|
75
75
|
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-use-state
|
|
76
76
|
*/
|
|
@@ -49,7 +49,7 @@ export const getTypescriptNamingConventionRule = ({
|
|
|
49
49
|
regex: "^(ALL|GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)$"
|
|
50
50
|
},
|
|
51
51
|
format: null,
|
|
52
|
-
selector: ["variableLike"]
|
|
52
|
+
selector: ["variableLike", "memberLike"]
|
|
53
53
|
},
|
|
54
54
|
// allow variable-likes called exactly "_"
|
|
55
55
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haltcase/style",
|
|
3
|
-
"version": "8.0.0-canary.
|
|
3
|
+
"version": "8.0.0-canary.11",
|
|
4
4
|
"description": "haltcase's web ecosystem style guide & configurations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -55,9 +55,11 @@
|
|
|
55
55
|
"./typescript/bundler": "./typescript/tsconfig.bundler.json",
|
|
56
56
|
"./typescript/next": "./typescript/tsconfig.next.json",
|
|
57
57
|
"./typescript/node": "./typescript/tsconfig.node.json",
|
|
58
|
+
"./typescript/node-ts": "./typescript/tsconfig.node-ts.json",
|
|
58
59
|
"./typescript/node18": "./typescript/tsconfig.node18.json",
|
|
59
60
|
"./typescript/node20": "./typescript/tsconfig.node20.json",
|
|
60
61
|
"./typescript/node22": "./typescript/tsconfig.node22.json",
|
|
62
|
+
"./typescript/node24": "./typescript/tsconfig.node24.json",
|
|
61
63
|
"./typescript/web": "./typescript/tsconfig.web.json"
|
|
62
64
|
},
|
|
63
65
|
"files": [
|
|
@@ -88,62 +90,66 @@
|
|
|
88
90
|
"@babel/core": "^7.26.9",
|
|
89
91
|
"@babel/eslint-parser": "^7.26.8",
|
|
90
92
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
91
|
-
"@eslint-react/eslint-plugin": "^
|
|
92
|
-
"@
|
|
93
|
-
"@stylistic/eslint-plugin-jsx": "^3.1.0",
|
|
93
|
+
"@eslint-react/eslint-plugin": "^2.3.13",
|
|
94
|
+
"@stylistic/eslint-plugin-jsx": "^4.2.0",
|
|
94
95
|
"eslint-config-prettier": "^10.0.1",
|
|
95
96
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
96
|
-
"eslint-import-resolver-typescript": "^3.
|
|
97
|
+
"eslint-import-resolver-typescript": "^4.3.4",
|
|
97
98
|
"eslint-plugin-import-x": "^4.6.1",
|
|
98
99
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
99
100
|
"eslint-plugin-playwright": "^2.2.0",
|
|
100
101
|
"eslint-plugin-react": "^7.37.4",
|
|
101
|
-
"eslint-plugin-react-hooks": "^
|
|
102
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
103
|
+
"eslint-plugin-react-you-might-not-need-an-effect": "^0.8.3",
|
|
102
104
|
"eslint-plugin-regexp": "^2.7.0",
|
|
103
105
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
104
106
|
"eslint-plugin-testing-library": "^7.1.1",
|
|
105
|
-
"eslint-plugin-tsdoc": "^0.
|
|
106
|
-
"eslint-plugin-unicorn": "^
|
|
107
|
+
"eslint-plugin-tsdoc": "^0.5.0",
|
|
108
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
107
109
|
"postcss-html": "^1.8.0",
|
|
108
110
|
"prettier-plugin-packagejson": "^2.5.8",
|
|
109
|
-
"prettier-plugin-tailwindcss": "^0.
|
|
110
|
-
"stylelint-config-clean-order": "^
|
|
111
|
+
"prettier-plugin-tailwindcss": "^0.7.0",
|
|
112
|
+
"stylelint-config-clean-order": "^8.0.0",
|
|
111
113
|
"stylelint-config-html": "^1.1.0",
|
|
112
|
-
"stylelint-config-standard": "^
|
|
114
|
+
"stylelint-config-standard": "^39.0.1",
|
|
113
115
|
"stylelint-config-tailwindcss": "^1.0.0",
|
|
114
116
|
"stylelint-define-config": "^16.14.1",
|
|
115
|
-
"
|
|
117
|
+
"stylelint-order": "^7.0.0",
|
|
118
|
+
"typescript-eslint": "^8.40.0"
|
|
116
119
|
},
|
|
117
120
|
"devDependencies": {
|
|
118
|
-
"@actions/core": "^
|
|
119
|
-
"@actions/exec": "^
|
|
121
|
+
"@actions/core": "^2.0.1",
|
|
122
|
+
"@actions/exec": "^2.0.0",
|
|
120
123
|
"@actions/github": "^6.0.0",
|
|
121
|
-
"@commitlint/cli": "^
|
|
122
|
-
"@commitlint/config-conventional": "^
|
|
123
|
-
"@eslint/eslintrc": "^3.2.0",
|
|
124
|
+
"@commitlint/cli": "^20.2.0",
|
|
125
|
+
"@commitlint/config-conventional": "^20.2.0",
|
|
124
126
|
"@eslint/js": "^9.20.0",
|
|
125
|
-
"@
|
|
127
|
+
"@next/eslint-plugin-next": "^15.1.7",
|
|
128
|
+
"@octokit/types": "^16.0.0",
|
|
126
129
|
"@semantic-release/git": "^10.0.1",
|
|
127
130
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
128
131
|
"@types/node": "22",
|
|
129
|
-
"@typescript-eslint/types": "^8.
|
|
132
|
+
"@typescript-eslint/types": "^8.40.0",
|
|
130
133
|
"eslint": "^9.20.1",
|
|
131
|
-
"
|
|
132
|
-
"globals": "^15.15.0",
|
|
134
|
+
"globals": "^16.0.0",
|
|
133
135
|
"husky": "^9.1.7",
|
|
134
|
-
"lint-staged": "^
|
|
136
|
+
"lint-staged": "^16.1.0",
|
|
135
137
|
"prettier": "^3.5.1",
|
|
136
|
-
"semantic-release": "^
|
|
138
|
+
"semantic-release": "^25.0.2",
|
|
137
139
|
"stylelint": "^16.14.1",
|
|
138
|
-
"typescript": "^5.
|
|
140
|
+
"typescript": "^5.9.3"
|
|
139
141
|
},
|
|
140
142
|
"peerDependencies": {
|
|
143
|
+
"@next/eslint-plugin-next": ">=15.0.0 <17",
|
|
141
144
|
"eslint": ">=9",
|
|
142
145
|
"prettier": ">=3.0.0 <4",
|
|
143
146
|
"stylelint": ">=16.3.1 <17",
|
|
144
147
|
"typescript": ">=5.0.0 <6"
|
|
145
148
|
},
|
|
146
149
|
"peerDependenciesMeta": {
|
|
150
|
+
"@next/eslint-plugin-next": {
|
|
151
|
+
"optional": true
|
|
152
|
+
},
|
|
147
153
|
"eslint": {
|
|
148
154
|
"optional": true
|
|
149
155
|
},
|
|
@@ -157,7 +163,7 @@
|
|
|
157
163
|
"optional": true
|
|
158
164
|
}
|
|
159
165
|
},
|
|
160
|
-
"packageManager": "pnpm@10.
|
|
166
|
+
"packageManager": "pnpm@10.25.0",
|
|
161
167
|
"engines": {
|
|
162
168
|
"node": ">=20",
|
|
163
169
|
"pnpm": ">=10"
|
package/readme.md
CHANGED
|
@@ -90,7 +90,7 @@ export default getEslintConfig({
|
|
|
90
90
|
// treat *.js files as CommonJS instead of ES Modules
|
|
91
91
|
commonjs: true,
|
|
92
92
|
|
|
93
|
-
// for Next.js projects (implies `react`)
|
|
93
|
+
// for Next.js projects (implies `react`, requires `@next/eslint-plugin-next`)
|
|
94
94
|
nextjs: true,
|
|
95
95
|
|
|
96
96
|
// for Node.js projects
|
|
@@ -186,6 +186,47 @@ export default [
|
|
|
186
186
|
];
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
You can also enable TypeScript ESLint's
|
|
190
|
+
[`projectService`](https://typescript-eslint.io/packages/parser#projectservice):
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
import { getEslintConfig } from "@haltcase/style/eslint";
|
|
194
|
+
|
|
195
|
+
export default [
|
|
196
|
+
...getEslintConfig({
|
|
197
|
+
typescriptProject: {
|
|
198
|
+
projectService: true
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
];
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Because `eslint-import-resolver-typescript` [does not support
|
|
205
|
+
`projectService`](https://github.com/import-js/eslint-import-resolver-typescript/issues/282),
|
|
206
|
+
you should either:
|
|
207
|
+
|
|
208
|
+
1. Have a single `tsconfig.json` file in your root directory, including [project
|
|
209
|
+
references](https://www.typescriptlang.org/docs/handbook/project-references.html)
|
|
210
|
+
if necessary.
|
|
211
|
+
|
|
212
|
+
2. Explicitly pass your `tsconfig.json` paths:
|
|
213
|
+
|
|
214
|
+
```js
|
|
215
|
+
import { getEslintConfig } from "@haltcase/style/eslint";
|
|
216
|
+
|
|
217
|
+
export default [
|
|
218
|
+
...getEslintConfig({
|
|
219
|
+
typescriptProject: {
|
|
220
|
+
projectService: true,
|
|
221
|
+
tsconfigPaths: [
|
|
222
|
+
"./packages/**/tsconfig.json",
|
|
223
|
+
"./separate-package/tsconfig.json"
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
];
|
|
228
|
+
```
|
|
229
|
+
|
|
189
230
|
If you need to further customize the TypeScript behavior, use a separate config
|
|
190
231
|
with your own options, for example:
|
|
191
232
|
|
|
@@ -267,22 +308,24 @@ export default [
|
|
|
267
308
|
|
|
268
309
|
Several Typescript configs are available to cover various scenarios:
|
|
269
310
|
|
|
270
|
-
| Name | Description
|
|
271
|
-
| ------------------------------------ |
|
|
272
|
-
| `@haltcase/style/typescript/base` | Baseline config, intended to be extended from.
|
|
273
|
-
| `@haltcase/style/typescript/bundler` | For use in bundled projects, most commonly [Vite](https://vitejs.dev/) + [React](https://react.dev).
|
|
274
|
-
| `@haltcase/style/typescript/next` | For use in [Next.js](https://nextjs.org/) projects.
|
|
275
|
-
| `@haltcase/style/typescript/node` | Default Node config, currently targeting Node
|
|
276
|
-
| `@haltcase/style/typescript/
|
|
277
|
-
| `@haltcase/style/typescript/
|
|
278
|
-
| `@haltcase/style/typescript/
|
|
279
|
-
| `@haltcase/style/typescript/
|
|
311
|
+
| Name | Description |
|
|
312
|
+
| ------------------------------------ | -------------------------------------------------------------------------------------------------------- |
|
|
313
|
+
| `@haltcase/style/typescript/base` | Baseline config, intended to be extended from. |
|
|
314
|
+
| `@haltcase/style/typescript/bundler` | For use in bundled projects, most commonly [Vite](https://vitejs.dev/) + [React](https://react.dev). |
|
|
315
|
+
| `@haltcase/style/typescript/next` | For use in [Next.js](https://nextjs.org/) projects. See the [Next.js](#nextjs) section for more details. |
|
|
316
|
+
| `@haltcase/style/typescript/node` | Default Node config, currently targeting Node 24. |
|
|
317
|
+
| `@haltcase/style/typescript/node-ts` | Addon for other Node configs for use with Node's built-in TypeScript support. |
|
|
318
|
+
| `@haltcase/style/typescript/node18` | For projects targeting Node 18. |
|
|
319
|
+
| `@haltcase/style/typescript/node20` | For projects targeting Node 20. |
|
|
320
|
+
| `@haltcase/style/typescript/node22` | For projects targeting Node 22. |
|
|
321
|
+
| `@haltcase/style/typescript/node24` | For projects targeting Node 24. |
|
|
322
|
+
| `@haltcase/style/typescript/web` | For use in web projects. |
|
|
280
323
|
|
|
281
324
|
Typically, you'll only need to extend from one of these:
|
|
282
325
|
|
|
283
326
|
```json
|
|
284
327
|
{
|
|
285
|
-
"extends": "@haltcase/style/typescript/
|
|
328
|
+
"extends": "@haltcase/style/typescript/node"
|
|
286
329
|
}
|
|
287
330
|
```
|
|
288
331
|
|
|
@@ -366,6 +409,47 @@ If you use Tailwind, you can additionally extend from `@haltcase/style/stylelint
|
|
|
366
409
|
}
|
|
367
410
|
```
|
|
368
411
|
|
|
412
|
+
### Other workloads
|
|
413
|
+
|
|
414
|
+
#### Next.js
|
|
415
|
+
|
|
416
|
+
For Next.js projects, install `@next/eslint-plugin-next` as a development
|
|
417
|
+
dependency.
|
|
418
|
+
|
|
419
|
+
> [!TIP]
|
|
420
|
+
> Keep your Next.js and `@next/eslint-plugin-next` versions in sync for best
|
|
421
|
+
> compatibility.
|
|
422
|
+
|
|
423
|
+
```sh
|
|
424
|
+
# pnpm
|
|
425
|
+
pnpm add -D @next/eslint-plugin-next
|
|
426
|
+
|
|
427
|
+
# npm
|
|
428
|
+
npm i -D @next/eslint-plugin-next
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Then, enable the Next.js config in your ESLint configuration:
|
|
432
|
+
|
|
433
|
+
```ts
|
|
434
|
+
// eslint.config.js
|
|
435
|
+
import { getEslintConfig } from "@haltcase/style/eslint";
|
|
436
|
+
|
|
437
|
+
export default getEslintConfig({
|
|
438
|
+
nextjs: true
|
|
439
|
+
});
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
See the [ESLint section](#eslint) for more details.
|
|
443
|
+
|
|
444
|
+
If you're using TypeScript, you can extend from the Next.js-specific config:
|
|
445
|
+
|
|
446
|
+
```jsonc
|
|
447
|
+
// tsconfig.json
|
|
448
|
+
{
|
|
449
|
+
"extends": "@haltcase/style/typescript/next"
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
369
453
|
## contributing
|
|
370
454
|
|
|
371
455
|
Please read our [contributing](https://github.com/haltcase/style/blob/main/CONTRIBUTING.md)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-7/#path-rewriting-for-relative-paths
|
|
5
|
+
"rewriteRelativeImportExtensions": true,
|
|
6
|
+
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/#the---erasablesyntaxonly-option
|
|
7
|
+
"erasableSyntaxOnly": true,
|
|
8
|
+
"verbatimModuleSyntax": true
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
3
|
"extends": "./tsconfig.base.json",
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
"lib": ["
|
|
6
|
-
"module": "
|
|
5
|
+
"lib": ["es2024", "ESNext.Array", "ESNext.Collection", "ESNext.Iterator"],
|
|
6
|
+
// Use `"module": "node20"` when TypeScript 5.9+ is widely used
|
|
7
|
+
"module": "nodenext",
|
|
7
8
|
"target": "es2022",
|
|
8
9
|
"moduleResolution": "node16"
|
|
9
10
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"lib": [
|
|
6
|
+
"es2024",
|
|
7
|
+
"ESNext.Array",
|
|
8
|
+
"ESNext.Collection",
|
|
9
|
+
"ESNext.Iterator",
|
|
10
|
+
"ESNext.Promise"
|
|
11
|
+
],
|
|
12
|
+
// Use `"module": "node20"` when TypeScript 5.9+ is widely used
|
|
13
|
+
"module": "nodenext",
|
|
14
|
+
"target": "es2024",
|
|
15
|
+
"moduleResolution": "node16"
|
|
16
|
+
}
|
|
17
|
+
}
|