@haltcase/style 6.2.1-canary.1 → 7.0.0-canary.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/eslint/configs/browser.js +19 -0
- package/eslint/configs/cjs.js +1 -0
- package/eslint/configs/internal/base.js +180 -0
- package/eslint/configs/internal/commonjs.js +22 -0
- package/eslint/{rules → configs/internal}/es2015.js +14 -16
- package/eslint/configs/internal/simple-import-sort.js +24 -0
- package/eslint/configs/internal/tsdoc.js +17 -0
- package/eslint/{rules → configs/internal}/unicorn.js +116 -121
- package/eslint/configs/next.js +36 -0
- package/eslint/configs/node.js +19 -0
- package/eslint/configs/playwright-test.js +17 -0
- package/eslint/configs/react.js +54 -0
- package/eslint/configs/typescript.js +84 -0
- package/eslint/constants.js +12 -28
- package/eslint/index.js +27 -0
- package/eslint/rules/best-practice.js +250 -245
- package/eslint/rules/imports.js +94 -0
- package/eslint/rules/jsx-a11y.js +11 -10
- package/eslint/rules/playwright-test.js +25 -26
- package/eslint/rules/possible-errors.js +38 -45
- package/eslint/rules/react.js +105 -104
- package/eslint/rules/stylistic.js +83 -84
- package/eslint/rules/typescript/extension.js +55 -39
- package/eslint/rules/typescript/import.js +16 -15
- package/eslint/rules/typescript/index.js +109 -121
- package/eslint/rules/typescript/naming-convention.js +71 -0
- package/eslint/rules/variables.js +34 -34
- package/eslint/withFiles.js +15 -0
- package/package.json +58 -56
- package/prettier/index.js +4 -11
- package/readme.md +181 -98
- package/stylelint/_base.js +2 -4
- package/stylelint/index.js +6 -7
- package/stylelint/modules.js +7 -8
- package/stylelint/standard.js +2 -5
- package/typescript/tsconfig.base.json +2 -1
- package/typescript/tsconfig.bundler.json +7 -3
- package/typescript/tsconfig.next.json +14 -6
- package/typescript/tsconfig.node.json +1 -1
- package/typescript/tsconfig.node18.json +4 -7
- package/typescript/tsconfig.node20.json +4 -7
- package/typescript/tsconfig.node22.json +10 -0
- package/typescript/tsconfig.web.json +1 -1
- package/eslint/_base.js +0 -82
- package/eslint/astro.js +0 -40
- package/eslint/browser.js +0 -8
- package/eslint/cjs.js +0 -12
- package/eslint/jest.js +0 -28
- package/eslint/next.js +0 -38
- package/eslint/node.js +0 -8
- package/eslint/playwright-test.js +0 -8
- package/eslint/react.js +0 -18
- package/eslint/rules/import.js +0 -92
- package/eslint/rules/jest.js +0 -28
- package/eslint/rules/simple-import-sort.js +0 -23
- package/eslint/rules/tsdoc.js +0 -17
- package/eslint/rules/typescript/strict.js +0 -18
- package/eslint/typescript.js +0 -26
- package/eslint/utils/require-package.js +0 -44
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import { config } from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
import { getEslintBaseConfig } from "./internal/base.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {import("./internal/base.js").HaltcaseStyleOptions} [options]
|
|
8
|
+
*/
|
|
9
|
+
export const getEslintBrowserConfig = (options = {}) =>
|
|
10
|
+
config({
|
|
11
|
+
name: "Browser",
|
|
12
|
+
|
|
13
|
+
extends: [...getEslintBaseConfig(options)],
|
|
14
|
+
languageOptions: {
|
|
15
|
+
globals: {
|
|
16
|
+
...globals.browser
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getEslintCommonJsConfig } from "./internal/commonjs.js";
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @import { ProjectServiceOptions } from "@typescript-eslint/types"
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import babelParser from "@babel/eslint-parser";
|
|
8
|
+
import eslint from "@eslint/js";
|
|
9
|
+
import eslintPluginEslintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
10
|
+
// eslint-disable-next-line import-x/default
|
|
11
|
+
import eslintConfigPrettier from "eslint-config-prettier";
|
|
12
|
+
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
13
|
+
// eslint-disable-next-line import-x/default
|
|
14
|
+
import eslintRegexp from "eslint-plugin-regexp";
|
|
15
|
+
import { config } from "typescript-eslint";
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
allSupportedFiles,
|
|
19
|
+
configFiles,
|
|
20
|
+
ecmaVersion,
|
|
21
|
+
javascriptFiles,
|
|
22
|
+
scriptFiles
|
|
23
|
+
} from "../../constants.js";
|
|
24
|
+
import { bestPracticeRules } from "../../rules/best-practice.js";
|
|
25
|
+
import { importRules } from "../../rules/imports.js";
|
|
26
|
+
import { possibleErrorsRules } from "../../rules/possible-errors.js";
|
|
27
|
+
import { stylisticRules } from "../../rules/stylistic.js";
|
|
28
|
+
import { variablesRules } from "../../rules/variables.js";
|
|
29
|
+
import { getEslintNextConfig } from "../next.js";
|
|
30
|
+
import { getEslintReactConfig } from "../react.js";
|
|
31
|
+
import { getEslintTypescriptConfig } from "../typescript.js";
|
|
32
|
+
import { getEslintCommonJsConfig } from "./commonjs.js";
|
|
33
|
+
import { eslintEs2015Config } from "./es2015.js";
|
|
34
|
+
import { eslintSimpleImportSortConfig } from "./simple-import-sort.js";
|
|
35
|
+
import { eslintUnicornConfig } from "./unicorn.js";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @typedef {Object} HaltcaseStyleOptions
|
|
39
|
+
* @property {boolean} [browser] Whether to include browser rules and globals.
|
|
40
|
+
* @property {boolean} [commonjs] Whether to treat *.js files as CommonJS instead of ES Modules.
|
|
41
|
+
* @property {boolean} [nextjs] Whether to include Next.js rules (implies `react`).
|
|
42
|
+
* @property {boolean} [node] Whether to include Node.js rules.
|
|
43
|
+
* @property {boolean} [react] Whether to include React rules.
|
|
44
|
+
* @property {ProjectServiceOptions} [typescriptProjectServiceOptions = true] Custom TypeScript project service options for the `typescript-eslint` parser.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the common ESLint config for Node and browsers.
|
|
49
|
+
*
|
|
50
|
+
* @param {HaltcaseStyleOptions} options
|
|
51
|
+
*/
|
|
52
|
+
export const getEslintBaseConfig = (options = {}) =>
|
|
53
|
+
config(
|
|
54
|
+
{
|
|
55
|
+
name: "import-x/recommended",
|
|
56
|
+
plugins: {
|
|
57
|
+
"import-x": eslintPluginImportX
|
|
58
|
+
},
|
|
59
|
+
rules: {
|
|
60
|
+
...eslintPluginImportX.configs.recommended.rules
|
|
61
|
+
},
|
|
62
|
+
settings: {
|
|
63
|
+
"import-x/parsers": {
|
|
64
|
+
"@typescript-eslint/parser": [".ts"]
|
|
65
|
+
},
|
|
66
|
+
"import-x/resolver": {
|
|
67
|
+
typescript: true,
|
|
68
|
+
node: true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
name: "@haltcase/internal/base",
|
|
75
|
+
|
|
76
|
+
extends: [
|
|
77
|
+
{ name: "eslint/recommended", ...eslint.configs.recommended },
|
|
78
|
+
|
|
79
|
+
{ name: "prettier", ...eslintConfigPrettier },
|
|
80
|
+
|
|
81
|
+
{
|
|
82
|
+
name: "eslint-comments",
|
|
83
|
+
rules: {
|
|
84
|
+
...eslintPluginEslintComments.configs.recommended.rules
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
languageOptions: {
|
|
89
|
+
// global parser options
|
|
90
|
+
parserOptions: {
|
|
91
|
+
ecmaVersion,
|
|
92
|
+
sourceType: "module"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
linterOptions: {
|
|
96
|
+
reportUnusedDisableDirectives: "warn"
|
|
97
|
+
},
|
|
98
|
+
plugins: {
|
|
99
|
+
"@eslint-community/eslint-comments": eslintPluginEslintComments
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
{
|
|
104
|
+
name: "@haltcase/internal/Best practices",
|
|
105
|
+
files: allSupportedFiles,
|
|
106
|
+
rules: bestPracticeRules
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
...eslintEs2015Config,
|
|
110
|
+
|
|
111
|
+
{
|
|
112
|
+
name: "@haltcase/internal/Imports",
|
|
113
|
+
files: allSupportedFiles,
|
|
114
|
+
rules: importRules
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
{
|
|
118
|
+
name: "@haltcase/internal/Possible errors",
|
|
119
|
+
files: allSupportedFiles,
|
|
120
|
+
rules: possibleErrorsRules
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
{
|
|
124
|
+
name: "@haltcase/internal/Regular Expressions",
|
|
125
|
+
// eslint-disable-next-line import-x/no-named-as-default-member
|
|
126
|
+
...eslintRegexp.configs["flat/recommended"]
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
...eslintSimpleImportSortConfig,
|
|
130
|
+
|
|
131
|
+
{
|
|
132
|
+
name: "@haltcase/internal/Stylistic",
|
|
133
|
+
files: allSupportedFiles,
|
|
134
|
+
rules: stylisticRules
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
...eslintUnicornConfig,
|
|
138
|
+
|
|
139
|
+
{
|
|
140
|
+
name: "@haltcase/internal/Variables",
|
|
141
|
+
// files: allSupportedFiles,
|
|
142
|
+
rules: variablesRules
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
{
|
|
146
|
+
name: "@haltcase/internal/JavaScript files",
|
|
147
|
+
files: javascriptFiles,
|
|
148
|
+
languageOptions: {
|
|
149
|
+
parser: babelParser,
|
|
150
|
+
parserOptions: {
|
|
151
|
+
requireConfigFile: false
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
...getEslintTypescriptConfig(options),
|
|
157
|
+
|
|
158
|
+
...(options.nextjs ? getEslintNextConfig(options) : []),
|
|
159
|
+
...(options.react || options.nextjs ? getEslintReactConfig(options) : []),
|
|
160
|
+
|
|
161
|
+
{
|
|
162
|
+
name: "@haltcase/internal/Third-party config files (e.g., next.config.mjs)",
|
|
163
|
+
files: configFiles,
|
|
164
|
+
rules: {
|
|
165
|
+
// these files likely require default exports
|
|
166
|
+
"import-x/no-default-export": "off"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
{
|
|
171
|
+
name: "@haltcase/internal/Development-only helper scripts & Prisma database scripts",
|
|
172
|
+
files: scriptFiles,
|
|
173
|
+
rules: {
|
|
174
|
+
"no-console": "off",
|
|
175
|
+
"unicorn/no-process-exit": "off"
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
...getEslintCommonJsConfig(options)
|
|
180
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { config } from "typescript-eslint";
|
|
2
|
+
|
|
3
|
+
import { commonJsFiles, commonJsOnlyFiles } from "../../constants.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {import("./base.js").HaltcaseStyleOptions} [options]
|
|
7
|
+
*/
|
|
8
|
+
export const getEslintCommonJsConfig = (options = {}) =>
|
|
9
|
+
config({
|
|
10
|
+
name: "@haltcase/internal/CommonJS files",
|
|
11
|
+
|
|
12
|
+
files: options.commonjs ? commonJsFiles : commonJsOnlyFiles,
|
|
13
|
+
languageOptions: {
|
|
14
|
+
parserOptions: {
|
|
15
|
+
sourceType: "script"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
strict: ["error", "global"],
|
|
20
|
+
"unicorn/prefer-module": "off"
|
|
21
|
+
}
|
|
22
|
+
});
|
|
@@ -1,71 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
import { config } from "typescript-eslint";
|
|
2
2
|
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
} = require("../constants");
|
|
3
|
+
export const eslintEs2015Config = config({
|
|
4
|
+
name: "@haltcase/internal/ES2015",
|
|
6
5
|
|
|
7
|
-
module.exports = {
|
|
8
6
|
rules: {
|
|
9
7
|
/**
|
|
10
8
|
* Disallow useless computed property keys.
|
|
11
9
|
*
|
|
12
10
|
* 🔧 Fixable - https://eslint.org/docs/rules/no-useless-computed-key
|
|
13
11
|
*/
|
|
14
|
-
"no-useless-computed-key": warn,
|
|
12
|
+
"no-useless-computed-key": "warn",
|
|
15
13
|
/**
|
|
16
14
|
* Disallow renaming import, export, and destructured assignments to the
|
|
17
15
|
* same name.
|
|
18
16
|
*
|
|
19
17
|
* 🔧 Fixable - https://eslint.org/docs/rules/no-useless-rename
|
|
20
18
|
*/
|
|
21
|
-
"no-useless-rename": warn,
|
|
19
|
+
"no-useless-rename": "warn",
|
|
22
20
|
/**
|
|
23
21
|
* Require `let` or `const` instead of `var`.
|
|
24
22
|
*
|
|
25
23
|
* 🔧 Fixable - https://eslint.org/docs/rules/no-var
|
|
26
24
|
*/
|
|
27
|
-
"no-var": error,
|
|
25
|
+
"no-var": "error",
|
|
28
26
|
/**
|
|
29
27
|
* Require object literal shorthand syntax.
|
|
30
28
|
*
|
|
31
29
|
* 🔧 Fixable - https://eslint.org/docs/rules/object-shorthand
|
|
32
30
|
*/
|
|
33
|
-
"object-shorthand": warn,
|
|
31
|
+
"object-shorthand": "warn",
|
|
34
32
|
/**
|
|
35
33
|
* Require default to `const` instead of `let`.
|
|
36
34
|
*
|
|
37
35
|
* 🔧 Fixable - https://eslint.org/docs/rules/prefer-const
|
|
38
36
|
*/
|
|
39
|
-
"prefer-const": warn,
|
|
37
|
+
"prefer-const": "warn",
|
|
40
38
|
/**
|
|
41
39
|
* Disallow parseInt() in favor of binary, octal, and hexadecimal literals.
|
|
42
40
|
*
|
|
43
41
|
* 🔧 Fixable - https://eslint.org/docs/rules/prefer-numeric-literals
|
|
44
42
|
*/
|
|
45
|
-
"prefer-numeric-literals": error,
|
|
43
|
+
"prefer-numeric-literals": "error",
|
|
46
44
|
/**
|
|
47
45
|
* Require using rest parameters instead of `arguments`.
|
|
48
46
|
*
|
|
49
47
|
* 🚫 Not fixable - https://eslint.org/docs/rules/prefer-rest-params
|
|
50
48
|
*/
|
|
51
|
-
"prefer-rest-params": error,
|
|
49
|
+
"prefer-rest-params": "error",
|
|
52
50
|
/**
|
|
53
51
|
* Require using spread syntax instead of `.apply()`.
|
|
54
52
|
*
|
|
55
53
|
* 🚫 Not fixable - https://eslint.org/docs/rules/prefer-spread
|
|
56
54
|
*/
|
|
57
|
-
"prefer-spread": error,
|
|
55
|
+
"prefer-spread": "error",
|
|
58
56
|
/**
|
|
59
57
|
* Require using template literals instead of string concatenation.
|
|
60
58
|
*
|
|
61
59
|
* 🔧 Fixable - https://eslint.org/docs/rules/prefer-template
|
|
62
60
|
*/
|
|
63
|
-
"prefer-template": warn,
|
|
61
|
+
"prefer-template": "warn",
|
|
64
62
|
/**
|
|
65
63
|
* Require a `Symbol` description.
|
|
66
64
|
*
|
|
67
65
|
* 🚫 Not fixable - https://eslint.org/docs/rules/symbol-description
|
|
68
66
|
*/
|
|
69
|
-
"symbol-description": error
|
|
67
|
+
"symbol-description": "error"
|
|
70
68
|
}
|
|
71
|
-
};
|
|
69
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
|
|
2
|
+
import { config } from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
export const eslintSimpleImportSortConfig = config({
|
|
5
|
+
name: "@haltcase/internal/Import & export sorting",
|
|
6
|
+
|
|
7
|
+
plugins: {
|
|
8
|
+
"simple-import-sort": eslintPluginSimpleImportSort
|
|
9
|
+
},
|
|
10
|
+
rules: {
|
|
11
|
+
/**
|
|
12
|
+
* Enforce export sort order.
|
|
13
|
+
*
|
|
14
|
+
* 🔧 Fixable - https://github.com/lydell/eslint-plugin-simple-import-sort#exports
|
|
15
|
+
*/
|
|
16
|
+
"simple-import-sort/exports": "error",
|
|
17
|
+
/**
|
|
18
|
+
* Enforce import sort order.
|
|
19
|
+
*
|
|
20
|
+
* 🔧 Fixable - https://github.com/lydell/eslint-plugin-simple-import-sort#imports
|
|
21
|
+
*/
|
|
22
|
+
"simple-import-sort/imports": "error"
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import eslintPluginTsdoc from "eslint-plugin-tsdoc";
|
|
2
|
+
import { config } from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
export const eslintTsdocConfig = config({
|
|
5
|
+
name: "@haltcase/internal/TSDoc comments",
|
|
6
|
+
plugins: {
|
|
7
|
+
tsdoc: eslintPluginTsdoc
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
/**
|
|
11
|
+
* Require TSDoc comments conform to the TSDoc specification.
|
|
12
|
+
*
|
|
13
|
+
* 🚫 Not fixable - https://github.com/microsoft/tsdoc/tree/master/eslint-plugin
|
|
14
|
+
*/
|
|
15
|
+
"tsdoc/syntax": "error"
|
|
16
|
+
}
|
|
17
|
+
});
|