@haltcase/style 6.2.1 → 7.0.0-canary.10
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 +27 -0
- package/eslint/configs/cjs.js +13 -0
- package/eslint/configs/internal/base.js +178 -0
- package/eslint/configs/internal/commonjs.js +22 -0
- package/eslint/{rules → configs/internal}/es2015.js +17 -16
- package/eslint/configs/internal/simple-import-sort.js +27 -0
- package/eslint/configs/internal/tsdoc.js +20 -0
- package/eslint/{rules → configs/internal}/unicorn.js +118 -126
- package/eslint/configs/next.js +50 -0
- package/eslint/configs/node.js +27 -0
- package/eslint/configs/playwright-test.js +21 -0
- package/eslint/configs/react.js +109 -0
- package/eslint/configs/typescript.js +106 -0
- package/eslint/constants.js +23 -28
- package/eslint/index.js +33 -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-x.js +78 -0
- package/eslint/rules/react.js +20 -113
- package/eslint/rules/stylistic-jsx.js +17 -0
- package/eslint/rules/stylistic.js +83 -84
- package/eslint/rules/typescript/extension.js +68 -39
- package/eslint/rules/typescript/import.js +16 -15
- package/eslint/rules/typescript/index.js +110 -121
- package/eslint/rules/typescript/naming-convention.js +121 -0
- package/eslint/rules/variables.js +34 -34
- package/eslint/withFiles.js +15 -0
- package/package.json +53 -59
- package/prettier/index.js +4 -11
- package/readme.md +183 -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,50 @@
|
|
|
1
|
+
import pluginNextjs from "@next/eslint-plugin-next";
|
|
2
|
+
import { config } from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
allSupportedFiles,
|
|
6
|
+
nextJsApiRoutes,
|
|
7
|
+
nextJsMetadataFiles,
|
|
8
|
+
nextJsPageFiles
|
|
9
|
+
} from "../constants.js";
|
|
10
|
+
import { getEslintBaseConfig } from "./internal/base.js";
|
|
11
|
+
import { getEslintNodeConfigInternal } from "./node.js";
|
|
12
|
+
import { getEslintReactConfigInternal } from "./react.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
16
|
+
*/
|
|
17
|
+
export const getEslintNextConfig = (options = {}) =>
|
|
18
|
+
config(
|
|
19
|
+
...getEslintBaseConfig(options),
|
|
20
|
+
...getEslintNodeConfigInternal(options),
|
|
21
|
+
...getEslintNextConfigInternal(options)
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
26
|
+
*/
|
|
27
|
+
export const getEslintNextConfigInternal = (options = {}) =>
|
|
28
|
+
config(
|
|
29
|
+
...getEslintReactConfigInternal(options),
|
|
30
|
+
{
|
|
31
|
+
name: "@haltcase/nextjs",
|
|
32
|
+
|
|
33
|
+
files: allSupportedFiles,
|
|
34
|
+
plugins: {
|
|
35
|
+
"@next/next": pluginNextjs
|
|
36
|
+
},
|
|
37
|
+
rules: {
|
|
38
|
+
...pluginNextjs.configs.recommended.rules,
|
|
39
|
+
...pluginNextjs.configs["core-web-vitals"].rules
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "Next.js page files and API routes",
|
|
44
|
+
|
|
45
|
+
files: [...nextJsPageFiles, ...nextJsApiRoutes, ...nextJsMetadataFiles],
|
|
46
|
+
rules: {
|
|
47
|
+
"import-x/no-default-export": "off"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import { config } from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
import { getEslintBaseConfig } from "./internal/base.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
8
|
+
*/
|
|
9
|
+
export const getEslintNodeConfig = (options = {}) =>
|
|
10
|
+
config(
|
|
11
|
+
...getEslintNodeConfigInternal(options),
|
|
12
|
+
...getEslintBaseConfig(options)
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
17
|
+
*/
|
|
18
|
+
export const getEslintNodeConfigInternal = (_options = {}) =>
|
|
19
|
+
config({
|
|
20
|
+
name: "@haltcase/Node.js",
|
|
21
|
+
|
|
22
|
+
languageOptions: {
|
|
23
|
+
globals: {
|
|
24
|
+
...globals.node
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import eslintPluginPlaywright from "eslint-plugin-playwright";
|
|
2
|
+
import { config } from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
import { playwrightTestRules } from "../rules/playwright-test.js";
|
|
5
|
+
|
|
6
|
+
const playwrightRecommendedConfig =
|
|
7
|
+
eslintPluginPlaywright.configs["flat/recommended"];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
11
|
+
*/
|
|
12
|
+
export const getEslintPlaywrightTestConfig = (_options = {}) =>
|
|
13
|
+
config({
|
|
14
|
+
...playwrightRecommendedConfig,
|
|
15
|
+
|
|
16
|
+
name: "Playwright tests",
|
|
17
|
+
|
|
18
|
+
rules: {
|
|
19
|
+
...playwrightTestRules
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import eslintPluginReact from "@eslint-react/eslint-plugin";
|
|
2
|
+
import eslintStylisticJsx from "@stylistic/eslint-plugin-jsx";
|
|
3
|
+
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
4
|
+
import eslintPluginJsxA11y from "eslint-plugin-jsx-a11y";
|
|
5
|
+
import eslintPluginReactOriginal from "eslint-plugin-react";
|
|
6
|
+
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
|
|
7
|
+
import { config } from "typescript-eslint";
|
|
8
|
+
|
|
9
|
+
import { jsxFiles, typescriptJsxFiles } from "../constants.js";
|
|
10
|
+
import { jsxA11yRules } from "../rules/jsx-a11y.js";
|
|
11
|
+
import { reactRules } from "../rules/react.js";
|
|
12
|
+
import { reactXRules } from "../rules/react-x.js";
|
|
13
|
+
import { stylisticJsxRules } from "../rules/stylistic-jsx.js";
|
|
14
|
+
import { getEslintBaseConfig } from "./internal/base.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
18
|
+
*/
|
|
19
|
+
export const getEslintReactConfig = (options) =>
|
|
20
|
+
config(
|
|
21
|
+
...getEslintBaseConfig(options),
|
|
22
|
+
...getEslintReactConfigInternal(options)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
27
|
+
*/
|
|
28
|
+
export const getEslintReactConfigInternal = (_options = {}) =>
|
|
29
|
+
config(
|
|
30
|
+
{
|
|
31
|
+
name: "@haltcase/react",
|
|
32
|
+
|
|
33
|
+
files: jsxFiles,
|
|
34
|
+
|
|
35
|
+
extends: [
|
|
36
|
+
{
|
|
37
|
+
name: "@haltcase/react/jsx-eslint/react",
|
|
38
|
+
plugins: {
|
|
39
|
+
// @ts-expect-error see https://github.com/jsx-eslint/eslint-plugin-react/pull/3840
|
|
40
|
+
react: eslintPluginReactOriginal
|
|
41
|
+
},
|
|
42
|
+
rules: {
|
|
43
|
+
...reactRules
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
{
|
|
48
|
+
name: "@haltcase/react/stylistic",
|
|
49
|
+
plugins: {
|
|
50
|
+
"@stylistic/jsx": eslintStylisticJsx
|
|
51
|
+
},
|
|
52
|
+
rules: {
|
|
53
|
+
...stylisticJsxRules
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
{
|
|
58
|
+
name: "@haltcase/react/hooks",
|
|
59
|
+
plugins: {
|
|
60
|
+
"react-hooks": eslintPluginReactHooks
|
|
61
|
+
},
|
|
62
|
+
rules: {
|
|
63
|
+
...eslintPluginReactHooks.configs.recommended.rules
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
name: "@haltcase/react/jsx-a11y",
|
|
69
|
+
...eslintPluginJsxA11y.flatConfigs.recommended
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
{
|
|
73
|
+
name: "@haltcase/react/import-x",
|
|
74
|
+
...eslintPluginImportX.flatConfigs.react
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
settings: {
|
|
78
|
+
react: {
|
|
79
|
+
version: "detect"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
rules: {
|
|
84
|
+
...jsxA11yRules
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
{
|
|
89
|
+
...eslintPluginReact.configs.recommended,
|
|
90
|
+
|
|
91
|
+
name: "@haltcase/react/recommended",
|
|
92
|
+
|
|
93
|
+
files: typescriptJsxFiles,
|
|
94
|
+
rules: {
|
|
95
|
+
...reactXRules
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
{
|
|
100
|
+
...eslintPluginReact.configs["recommended-type-checked"],
|
|
101
|
+
|
|
102
|
+
name: "@haltcase/react/recommended-type-checked",
|
|
103
|
+
|
|
104
|
+
files: typescriptJsxFiles,
|
|
105
|
+
rules: {
|
|
106
|
+
...reactXRules
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import eslintConfigPrettier from "eslint-config-prettier";
|
|
2
|
+
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
3
|
+
import { config, configs, parser, plugin } from "typescript-eslint";
|
|
4
|
+
|
|
5
|
+
import { typescriptFiles, typescriptJsxFiles } from "../constants.js";
|
|
6
|
+
import { typescriptExtensionRules } from "../rules/typescript/extension.js";
|
|
7
|
+
import { typescriptImportRules } from "../rules/typescript/import.js";
|
|
8
|
+
import { typescriptBaseRules } from "../rules/typescript/index.js";
|
|
9
|
+
import { getTypescriptNamingConventionRule } from "../rules/typescript/naming-convention.js";
|
|
10
|
+
import { eslintTsdocConfig } from "./internal/tsdoc.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
14
|
+
*/
|
|
15
|
+
export const getEslintTypescriptConfig = (options = {}) => {
|
|
16
|
+
/** @type {import("typescript-eslint").ConfigWithExtends["languageOptions"]} */
|
|
17
|
+
const languageOptions = {
|
|
18
|
+
parser,
|
|
19
|
+
parserOptions: {
|
|
20
|
+
ecmaFeatures: {
|
|
21
|
+
jsx: options.react || undefined,
|
|
22
|
+
modules: true
|
|
23
|
+
},
|
|
24
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/3788#issuecomment-905094436
|
|
25
|
+
jsxPragma: null,
|
|
26
|
+
project: options.typescriptProject ?? true
|
|
27
|
+
// use `projectService` when VS Code supports it properly
|
|
28
|
+
// https://github.com/microsoft/vscode-eslint/issues/1911
|
|
29
|
+
// projectService: options.typescriptProjectServiceOptions ?? true
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return config(
|
|
34
|
+
{
|
|
35
|
+
name: "@haltcase/internal/TypeScript files",
|
|
36
|
+
|
|
37
|
+
files: typescriptFiles,
|
|
38
|
+
|
|
39
|
+
extends: [
|
|
40
|
+
...configs.recommendedTypeChecked,
|
|
41
|
+
...configs.strictTypeChecked,
|
|
42
|
+
...configs.stylisticTypeChecked,
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
name: "import-x/typescript",
|
|
46
|
+
...eslintPluginImportX.configs.typescript
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
{ name: "prettier", ...eslintConfigPrettier },
|
|
50
|
+
|
|
51
|
+
...eslintTsdocConfig
|
|
52
|
+
],
|
|
53
|
+
|
|
54
|
+
languageOptions,
|
|
55
|
+
|
|
56
|
+
rules: {
|
|
57
|
+
...typescriptBaseRules,
|
|
58
|
+
...typescriptExtensionRules,
|
|
59
|
+
...typescriptImportRules,
|
|
60
|
+
...getTypescriptNamingConventionRule()
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
settings: {
|
|
64
|
+
"import-x/resolver": {
|
|
65
|
+
typescript: true
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "@haltcase/internal/TypeScript TSX files",
|
|
71
|
+
|
|
72
|
+
files: typescriptJsxFiles,
|
|
73
|
+
languageOptions,
|
|
74
|
+
|
|
75
|
+
plugins: {
|
|
76
|
+
"@typescript-eslint": plugin
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
rules: {
|
|
80
|
+
...getTypescriptNamingConventionRule({
|
|
81
|
+
isTsx: true
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
// special accommodations for non-TSX component-like files;
|
|
87
|
+
// specifically, this was added to allow PascaleCase'd declarations
|
|
88
|
+
// of extended components with Mantine, which uses e.g., `Button.extend()`
|
|
89
|
+
// to create a customized instance of a UI component
|
|
90
|
+
name: "@haltcase/internal/TypeScript component files",
|
|
91
|
+
|
|
92
|
+
files: ["**/components/*.ts"],
|
|
93
|
+
languageOptions,
|
|
94
|
+
|
|
95
|
+
plugins: {
|
|
96
|
+
"@typescript-eslint": plugin
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
rules: {
|
|
100
|
+
...getTypescriptNamingConventionRule({
|
|
101
|
+
isComponentLike: true
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
};
|
package/eslint/constants.js
CHANGED
|
@@ -1,32 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
export const ecmaVersion = 2021;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export const commonJsOnlyFiles = ["**/*.cjs"];
|
|
4
|
+
export const commonJsFiles = ["**/*.{c,}js"];
|
|
5
|
+
export const javascriptFiles = ["**/*.{m,}js{x,}"];
|
|
6
|
+
export const typescriptFiles = ["**/*.{m,}ts{x,}"];
|
|
7
|
+
export const javascriptJsxFiles = ["**/*.{m,}jsx"];
|
|
8
|
+
export const typescriptJsxFiles = ["**/*.{m,}tsx"];
|
|
9
|
+
export const jsxFiles = ["**/*.{c,m,}{js,ts}x"];
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
typescriptFiles: ["*.ts?(x)"],
|
|
11
|
+
export const configFiles = ["**/*.config.{m,}{js,ts}"];
|
|
12
|
+
export const scriptFiles = ["**/scripts/*", "**/prisma/*"];
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export const nextJsPageFiles = ["**/{pages,app}/**/*.{m,}{js,ts}x"];
|
|
15
|
+
export const nextJsApiRoutes = [
|
|
16
|
+
"**/pages/api/**/*.{m,}{js,ts}",
|
|
17
|
+
"**/app/**/route.{m,}{js,ts}x"
|
|
18
|
+
];
|
|
19
|
+
export const nextJsMetadataFiles = [
|
|
20
|
+
"**/app/{apple-,}icon.{js,ts}x",
|
|
21
|
+
"**/app/manifest.{js,ts}",
|
|
22
|
+
"**/app/robots.{js,ts}",
|
|
23
|
+
"**/app/sitemap.{js,ts}",
|
|
24
|
+
"**/app/{opengraph,twitter}-image.{js,ts}x"
|
|
25
|
+
];
|
|
17
26
|
|
|
18
|
-
|
|
19
|
-
nextJsApiRoutes: ["**/{pages,app}/api/**/*.{m,}{js,ts}"],
|
|
20
|
-
|
|
21
|
-
astroFiles: ["*.astro"],
|
|
22
|
-
|
|
23
|
-
commonJsOverrides: {
|
|
24
|
-
parserOptions: {
|
|
25
|
-
sourceType: "script"
|
|
26
|
-
},
|
|
27
|
-
rules: {
|
|
28
|
-
strict: ["error", "global"],
|
|
29
|
-
"unicorn/prefer-module": "off"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
27
|
+
export const allSupportedFiles = ["**/*.{c,m,}{js,ts}{x,}"];
|
package/eslint/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { config } from "typescript-eslint";
|
|
2
|
+
|
|
3
|
+
import { getEslintBrowserConfigInternal } from "./configs/browser.js";
|
|
4
|
+
import { getEslintBaseConfig } from "./configs/internal/base.js";
|
|
5
|
+
import { getEslintNextConfigInternal } from "./configs/next.js";
|
|
6
|
+
import { getEslintNodeConfigInternal } from "./configs/node.js";
|
|
7
|
+
import { getEslintReactConfigInternal } from "./configs/react.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import("./configs/internal/base.js").HaltcaseStyleCreator}
|
|
11
|
+
*/
|
|
12
|
+
export const getEslintConfig = (options = {}) =>
|
|
13
|
+
config(
|
|
14
|
+
...getEslintBaseConfig(options),
|
|
15
|
+
...(options.browser ? getEslintBrowserConfigInternal(options) : []),
|
|
16
|
+
...(options.node ? getEslintNodeConfigInternal(options) : []),
|
|
17
|
+
|
|
18
|
+
...(options.nextjs ? getEslintNextConfigInternal(options) : []),
|
|
19
|
+
...(options.react && !options.nextjs
|
|
20
|
+
? getEslintReactConfigInternal(options)
|
|
21
|
+
: [])
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line import-x/no-default-export
|
|
25
|
+
export default getEslintConfig;
|
|
26
|
+
|
|
27
|
+
export { getEslintBrowserConfig } from "./configs/browser.js";
|
|
28
|
+
export { getEslintCommonJsConfig } from "./configs/cjs.js";
|
|
29
|
+
export { getEslintNextConfig } from "./configs/next.js";
|
|
30
|
+
export { getEslintNodeConfig } from "./configs/node.js";
|
|
31
|
+
export { getEslintReactConfig } from "./configs/react.js";
|
|
32
|
+
export { getEslintTypescriptConfig } from "./configs/typescript.js";
|
|
33
|
+
export { withFiles } from "./withFiles.js";
|