@haltcase/style 7.0.0-canary.6 → 7.0.0-canary.8
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 +2 -2
- package/eslint/configs/cjs.js +1 -1
- package/eslint/configs/internal/base.js +5 -5
- package/eslint/configs/internal/commonjs.js +1 -1
- package/eslint/configs/internal/es2015.js +3 -0
- package/eslint/configs/internal/simple-import-sort.js +3 -0
- package/eslint/configs/internal/tsdoc.js +3 -0
- package/eslint/configs/internal/unicorn.js +3 -0
- package/eslint/configs/next.js +4 -4
- package/eslint/configs/node.js +2 -2
- package/eslint/configs/playwright-test.js +1 -1
- package/eslint/configs/react.js +69 -46
- package/eslint/configs/typescript.js +21 -2
- package/eslint/constants.js +12 -1
- package/eslint/index.js +2 -2
- package/eslint/rules/react-x.js +25 -14
- package/eslint/rules/react.js +7 -1
- package/eslint/rules/typescript/naming-convention.js +13 -3
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { config } from "typescript-eslint";
|
|
|
4
4
|
import { getEslintBaseConfig } from "./internal/base.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
7
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
8
8
|
*/
|
|
9
9
|
export const getEslintBrowserConfig = (options = {}) =>
|
|
10
10
|
config(
|
|
@@ -13,7 +13,7 @@ export const getEslintBrowserConfig = (options = {}) =>
|
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @
|
|
16
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
17
17
|
*/
|
|
18
18
|
export const getEslintBrowserConfigInternal = (_options = {}) =>
|
|
19
19
|
config({
|
package/eslint/configs/cjs.js
CHANGED
|
@@ -4,7 +4,7 @@ import { getEslintBaseConfig } from "./internal/base.js";
|
|
|
4
4
|
import { getEslintCommonJsConfigInternal } from "./internal/commonjs.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
7
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
8
8
|
*/
|
|
9
9
|
export const getEslintCommonJsConfig = (options) =>
|
|
10
10
|
config(
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @import { ParserOptions } from "@typescript-eslint/types"
|
|
5
3
|
*/
|
|
@@ -7,10 +5,8 @@
|
|
|
7
5
|
import babelParser from "@babel/eslint-parser";
|
|
8
6
|
import eslint from "@eslint/js";
|
|
9
7
|
import eslintPluginEslintComments from "@eslint-community/eslint-plugin-eslint-comments";
|
|
10
|
-
// eslint-disable-next-line import-x/default
|
|
11
8
|
import eslintConfigPrettier from "eslint-config-prettier";
|
|
12
9
|
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
13
|
-
// eslint-disable-next-line import-x/default
|
|
14
10
|
import eslintRegexp from "eslint-plugin-regexp";
|
|
15
11
|
import { config } from "typescript-eslint";
|
|
16
12
|
|
|
@@ -45,10 +41,14 @@ import { eslintUnicornConfig } from "./unicorn.js";
|
|
|
45
41
|
* property {ProjectServiceOptions} [typescriptProjectServiceOptions = true] Custom TypeScript project service options for the `typescript-eslint` parser.
|
|
46
42
|
*/
|
|
47
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {(options?: HaltcaseStyleOptions) => Awaited<import("typescript-eslint").Config>} HaltcaseStyleCreator
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
48
|
/**
|
|
49
49
|
* Get the common ESLint config for Node and browsers.
|
|
50
50
|
*
|
|
51
|
-
* @
|
|
51
|
+
* @type {HaltcaseStyleCreator}
|
|
52
52
|
*/
|
|
53
53
|
export const getEslintBaseConfig = (options = {}) =>
|
|
54
54
|
config(
|
|
@@ -3,7 +3,7 @@ import { config } from "typescript-eslint";
|
|
|
3
3
|
import { commonJsFiles, commonJsOnlyFiles } from "../../constants.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @
|
|
6
|
+
* @type {import("./base.js").HaltcaseStyleCreator}
|
|
7
7
|
*/
|
|
8
8
|
export const getEslintCommonJsConfigInternal = (options = {}) =>
|
|
9
9
|
config({
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
|
|
2
2
|
import { config } from "typescript-eslint";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @type {ReturnType<import("./base.js").HaltcaseStyleCreator>}
|
|
6
|
+
*/
|
|
4
7
|
export const eslintSimpleImportSortConfig = config({
|
|
5
8
|
name: "@haltcase/internal/Import & export sorting",
|
|
6
9
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import eslintPluginTsdoc from "eslint-plugin-tsdoc";
|
|
2
2
|
import { config } from "typescript-eslint";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @type {ReturnType<import("./base.js").HaltcaseStyleCreator>}
|
|
6
|
+
*/
|
|
4
7
|
export const eslintTsdocConfig = config({
|
|
5
8
|
name: "@haltcase/internal/TSDoc comments",
|
|
6
9
|
plugins: {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import eslintPluginUnicorn from "eslint-plugin-unicorn";
|
|
2
2
|
import { config } from "typescript-eslint";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @type {ReturnType<import("./base.js").HaltcaseStyleCreator>}
|
|
6
|
+
*/
|
|
4
7
|
export const eslintUnicornConfig = config({
|
|
5
8
|
name: "@haltcase/internal/Unicorn",
|
|
6
9
|
|
package/eslint/configs/next.js
CHANGED
|
@@ -4,6 +4,7 @@ import { config } from "typescript-eslint";
|
|
|
4
4
|
import {
|
|
5
5
|
javascriptFiles,
|
|
6
6
|
nextJsApiRoutes,
|
|
7
|
+
nextJsMetadataFiles,
|
|
7
8
|
nextJsPageFiles
|
|
8
9
|
} from "../constants.js";
|
|
9
10
|
import { getEslintBaseConfig } from "./internal/base.js";
|
|
@@ -11,7 +12,7 @@ import { getEslintNodeConfigInternal } from "./node.js";
|
|
|
11
12
|
import { getEslintReactConfigInternal } from "./react.js";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
|
-
* @
|
|
15
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
15
16
|
*/
|
|
16
17
|
export const getEslintNextConfig = (options = {}) =>
|
|
17
18
|
config(
|
|
@@ -21,7 +22,7 @@ export const getEslintNextConfig = (options = {}) =>
|
|
|
21
22
|
);
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
|
-
* @
|
|
25
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
25
26
|
*/
|
|
26
27
|
export const getEslintNextConfigInternal = (options = {}) =>
|
|
27
28
|
config(
|
|
@@ -33,7 +34,6 @@ export const getEslintNextConfigInternal = (options = {}) =>
|
|
|
33
34
|
plugins: {
|
|
34
35
|
"@next/next": pluginNextjs
|
|
35
36
|
},
|
|
36
|
-
// @ts-expect-error inference issue
|
|
37
37
|
rules: {
|
|
38
38
|
...pluginNextjs.configs.recommended.rules,
|
|
39
39
|
...pluginNextjs.configs["core-web-vitals"].rules
|
|
@@ -42,7 +42,7 @@ export const getEslintNextConfigInternal = (options = {}) =>
|
|
|
42
42
|
{
|
|
43
43
|
name: "Next.js page files and API routes",
|
|
44
44
|
|
|
45
|
-
files: [...nextJsPageFiles, ...nextJsApiRoutes],
|
|
45
|
+
files: [...nextJsPageFiles, ...nextJsApiRoutes, ...nextJsMetadataFiles],
|
|
46
46
|
rules: {
|
|
47
47
|
"import-x/no-default-export": "off"
|
|
48
48
|
}
|
package/eslint/configs/node.js
CHANGED
|
@@ -4,7 +4,7 @@ import { config } from "typescript-eslint";
|
|
|
4
4
|
import { getEslintBaseConfig } from "./internal/base.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
7
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
8
8
|
*/
|
|
9
9
|
export const getEslintNodeConfig = (options = {}) =>
|
|
10
10
|
config(
|
|
@@ -13,7 +13,7 @@ export const getEslintNodeConfig = (options = {}) =>
|
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @
|
|
16
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
17
17
|
*/
|
|
18
18
|
export const getEslintNodeConfigInternal = (_options = {}) =>
|
|
19
19
|
config({
|
|
@@ -7,7 +7,7 @@ const playwrightRecommendedConfig =
|
|
|
7
7
|
eslintPluginPlaywright.configs["flat/recommended"];
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @
|
|
10
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
11
11
|
*/
|
|
12
12
|
export const getEslintPlaywrightTestConfig = (_options = {}) =>
|
|
13
13
|
config({
|
package/eslint/configs/react.js
CHANGED
|
@@ -6,6 +6,7 @@ import eslintPluginReactOriginal from "eslint-plugin-react";
|
|
|
6
6
|
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
|
|
7
7
|
import { config } from "typescript-eslint";
|
|
8
8
|
|
|
9
|
+
import { jsxFiles, typescriptJsxFiles } from "../constants.js";
|
|
9
10
|
import { jsxA11yRules } from "../rules/jsx-a11y.js";
|
|
10
11
|
import { reactRules } from "../rules/react.js";
|
|
11
12
|
import { reactXRules } from "../rules/react-x.js";
|
|
@@ -13,7 +14,7 @@ import { stylisticJsxRules } from "../rules/stylistic-jsx.js";
|
|
|
13
14
|
import { getEslintBaseConfig } from "./internal/base.js";
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
* @
|
|
17
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
17
18
|
*/
|
|
18
19
|
export const getEslintReactConfig = (options) =>
|
|
19
20
|
config(
|
|
@@ -22,65 +23,87 @@ export const getEslintReactConfig = (options) =>
|
|
|
22
23
|
);
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
|
-
* @
|
|
26
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
26
27
|
*/
|
|
27
28
|
export const getEslintReactConfigInternal = (_options = {}) =>
|
|
28
|
-
config(
|
|
29
|
-
|
|
29
|
+
config(
|
|
30
|
+
{
|
|
31
|
+
name: "@haltcase/react",
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
...eslintPluginReact.configs["recommended-type-checked"],
|
|
34
|
-
name: "@haltcase/react/recommended-type-checked"
|
|
35
|
-
},
|
|
33
|
+
files: jsxFiles,
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
}
|
|
41
45
|
},
|
|
42
|
-
rules: {
|
|
43
|
-
...reactRules
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
+
}
|
|
51
65
|
},
|
|
52
|
-
rules: {
|
|
53
|
-
...stylisticJsxRules
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
66
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"react-hooks": eslintPluginReactHooks
|
|
67
|
+
{
|
|
68
|
+
name: "@haltcase/react/jsx-a11y",
|
|
69
|
+
...eslintPluginJsxA11y.flatConfigs.recommended
|
|
61
70
|
},
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
|
|
72
|
+
{
|
|
73
|
+
name: "@haltcase/react/import-x",
|
|
74
|
+
...eslintPluginImportX.flatConfigs.react
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
settings: {
|
|
78
|
+
react: {
|
|
79
|
+
version: "detect"
|
|
64
80
|
}
|
|
65
81
|
},
|
|
66
82
|
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
...eslintPluginJsxA11y.flatConfigs.recommended
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: "@haltcase/react/import-x",
|
|
73
|
-
...eslintPluginImportX.flatConfigs.react
|
|
83
|
+
rules: {
|
|
84
|
+
...jsxA11yRules
|
|
74
85
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
{
|
|
89
|
+
...eslintPluginReact.configs.recommended,
|
|
90
|
+
|
|
91
|
+
name: "@haltcase/react/recommended",
|
|
92
|
+
|
|
93
|
+
files: typescriptJsxFiles,
|
|
94
|
+
rules: {
|
|
95
|
+
...reactXRules
|
|
79
96
|
}
|
|
80
97
|
},
|
|
81
98
|
|
|
82
|
-
|
|
83
|
-
...
|
|
84
|
-
|
|
99
|
+
{
|
|
100
|
+
...eslintPluginReact.configs["recommended-type-checked"],
|
|
101
|
+
|
|
102
|
+
name: "@haltcase/react/recommended-type-checked",
|
|
103
|
+
|
|
104
|
+
files: typescriptJsxFiles,
|
|
105
|
+
rules: {
|
|
106
|
+
...reactXRules
|
|
107
|
+
}
|
|
85
108
|
}
|
|
86
|
-
|
|
109
|
+
);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line import-x/default
|
|
2
1
|
import eslintConfigPrettier from "eslint-config-prettier";
|
|
3
2
|
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
4
3
|
import { config, configs, parser, plugin } from "typescript-eslint";
|
|
@@ -11,7 +10,7 @@ import { getTypescriptNamingConventionRule } from "../rules/typescript/naming-co
|
|
|
11
10
|
import { eslintTsdocConfig } from "./internal/tsdoc.js";
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
|
-
* @
|
|
13
|
+
* @type {import("./internal/base.js").HaltcaseStyleCreator}
|
|
15
14
|
*/
|
|
16
15
|
export const getEslintTypescriptConfig = (options = {}) => {
|
|
17
16
|
/** @type {import("typescript-eslint").ConfigWithExtends["languageOptions"]} */
|
|
@@ -82,6 +81,26 @@ export const getEslintTypescriptConfig = (options = {}) => {
|
|
|
82
81
|
isTsx: true
|
|
83
82
|
})
|
|
84
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
|
+
}
|
|
85
104
|
}
|
|
86
105
|
);
|
|
87
106
|
};
|
package/eslint/constants.js
CHANGED
|
@@ -4,6 +4,7 @@ export const commonJsOnlyFiles = ["**/*.cjs"];
|
|
|
4
4
|
export const commonJsFiles = ["**/*.{c,}js"];
|
|
5
5
|
export const javascriptFiles = ["**/*.{m,}js{x,}"];
|
|
6
6
|
export const typescriptFiles = ["**/*.{m,}ts{x,}"];
|
|
7
|
+
export const javascriptJsxFiles = ["**/*.{m,}jsx"];
|
|
7
8
|
export const typescriptJsxFiles = ["**/*.{m,}tsx"];
|
|
8
9
|
export const jsxFiles = ["**/*.{c,m,}{js,ts}x"];
|
|
9
10
|
|
|
@@ -11,6 +12,16 @@ export const configFiles = ["**/*.config.{m,}{js,ts}"];
|
|
|
11
12
|
export const scriptFiles = ["**/scripts/*", "**/prisma/*"];
|
|
12
13
|
|
|
13
14
|
export const nextJsPageFiles = ["**/{pages,app}/**/*.{m,}{js,ts}x"];
|
|
14
|
-
export const nextJsApiRoutes = [
|
|
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
|
+
];
|
|
15
26
|
|
|
16
27
|
export const allSupportedFiles = ["**/*.{c,m,}{js,ts}{x,}"];
|
package/eslint/index.js
CHANGED
|
@@ -7,9 +7,9 @@ import { getEslintNodeConfigInternal } from "./configs/node.js";
|
|
|
7
7
|
import { getEslintReactConfigInternal } from "./configs/react.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @
|
|
10
|
+
* @type {import("./configs/internal/base.js").HaltcaseStyleCreator}
|
|
11
11
|
*/
|
|
12
|
-
export const getEslintConfig = (options) =>
|
|
12
|
+
export const getEslintConfig = (options = {}) =>
|
|
13
13
|
config(
|
|
14
14
|
...getEslintBaseConfig(options),
|
|
15
15
|
...(options.browser ? getEslintBrowserConfigInternal(options) : []),
|
package/eslint/rules/react-x.js
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
* @import { Linter } from "eslint"
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Rules we've decided to disable from the preset config.
|
|
7
|
+
*
|
|
8
|
+
* @type {Linter.RulesRecord}
|
|
9
|
+
*/
|
|
10
|
+
const disabledRules = {
|
|
11
|
+
/**
|
|
12
|
+
* Enforces that function components props are read-only.
|
|
13
|
+
*
|
|
14
|
+
* We have other checks that already disallow changing function parameters.
|
|
15
|
+
*
|
|
16
|
+
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/prefer-read-only-props
|
|
17
|
+
*/
|
|
18
|
+
"@eslint-react/prefer-read-only-props": "off"
|
|
19
|
+
};
|
|
20
|
+
|
|
5
21
|
/**
|
|
6
22
|
* Additional rules to enable on top of the preset config from
|
|
7
23
|
* `@eslint-react/eslint-plugin`
|
|
@@ -9,59 +25,54 @@
|
|
|
9
25
|
* @type {Linter.RulesRecord}
|
|
10
26
|
*/
|
|
11
27
|
export const reactXRules = {
|
|
28
|
+
...disabledRules,
|
|
29
|
+
|
|
12
30
|
/**
|
|
13
31
|
* Prevents using useless `fragment` components or `<>` syntax.
|
|
14
32
|
*
|
|
15
33
|
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/no-useless-fragment
|
|
16
34
|
*/
|
|
17
|
-
"no-useless-fragment": "error",
|
|
35
|
+
"@eslint-react/no-useless-fragment": "error",
|
|
18
36
|
|
|
19
37
|
/**
|
|
20
38
|
* Enforces using shorthand syntax for boolean attributes.
|
|
21
39
|
*
|
|
22
40
|
* 🔧 Fixable - https://eslint-react.xyz/docs/rules/prefer-shorthand-boolean
|
|
23
41
|
*/
|
|
24
|
-
"prefer-shorthand-boolean": "error",
|
|
42
|
+
"@eslint-react/prefer-shorthand-boolean": "error",
|
|
25
43
|
|
|
26
44
|
/**
|
|
27
45
|
* Enforces using shorthand syntax for fragments.
|
|
28
46
|
*
|
|
29
47
|
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/prefer-shorthand-fragment
|
|
30
48
|
*/
|
|
31
|
-
"prefer-shorthand-fragment": "error",
|
|
49
|
+
"@eslint-react/prefer-shorthand-fragment": "error",
|
|
32
50
|
|
|
33
51
|
/**
|
|
34
52
|
* Warns function calls made inside `useState` calls.
|
|
35
53
|
*
|
|
36
54
|
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/hooks-extra-prefer-use-state-lazy-initialization
|
|
37
55
|
*/
|
|
38
|
-
"hooks-extra/prefer-use-state-lazy-initialization": "error",
|
|
56
|
+
"@eslint-react/hooks-extra/prefer-use-state-lazy-initialization": "error",
|
|
39
57
|
|
|
40
58
|
/**
|
|
41
59
|
* Enforces naming conventions for components.
|
|
42
60
|
*
|
|
43
61
|
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-component-name
|
|
44
62
|
*/
|
|
45
|
-
"naming-convention/component-name": "warn",
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Enforces naming convention for JSX files.
|
|
49
|
-
*
|
|
50
|
-
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-filename
|
|
51
|
-
*/
|
|
52
|
-
"naming-convention/filename": "warn",
|
|
63
|
+
"@eslint-react/naming-convention/component-name": "warn",
|
|
53
64
|
|
|
54
65
|
/**
|
|
55
66
|
* Enforces consistent use of the JSX file extension.
|
|
56
67
|
*
|
|
57
68
|
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-filename-extension
|
|
58
69
|
*/
|
|
59
|
-
"naming-convention/filename-extension": "warn",
|
|
70
|
+
"@eslint-react/naming-convention/filename-extension": "warn",
|
|
60
71
|
|
|
61
72
|
/**
|
|
62
73
|
* Enforces destructuring and symmetric naming of useState hook value and setter variables.
|
|
63
74
|
*
|
|
64
75
|
* 🚫 Not fixable - https://eslint-react.xyz/docs/rules/naming-convention-use-state
|
|
65
76
|
*/
|
|
66
|
-
"naming-convention/use-state": "warn"
|
|
77
|
+
"@eslint-react/naming-convention/use-state": "warn"
|
|
67
78
|
};
|
package/eslint/rules/react.js
CHANGED
|
@@ -14,5 +14,11 @@ export const reactRules = {
|
|
|
14
14
|
*
|
|
15
15
|
* 🔧 Fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/HEAD/docs/rules/function-component-definition.md
|
|
16
16
|
*/
|
|
17
|
-
"react/function-component-definition":
|
|
17
|
+
"react/function-component-definition": [
|
|
18
|
+
"error",
|
|
19
|
+
{
|
|
20
|
+
namedComponents: "arrow-function",
|
|
21
|
+
unnamedComponents: "arrow-function"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
18
24
|
};
|
|
@@ -4,10 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @param {object} [options]
|
|
7
|
+
* @param {boolean} [options.isComponentLike = false] - Whether to treat as component-like (e.g., themed components without TSX/JSX).
|
|
7
8
|
* @param {boolean} [options.isTsx = false] - Whether to lint as TSX (JSX).
|
|
8
9
|
* @returns {Linter.RulesRecord}
|
|
9
10
|
*/
|
|
10
|
-
export const getTypescriptNamingConventionRule = ({
|
|
11
|
+
export const getTypescriptNamingConventionRule = ({
|
|
12
|
+
isComponentLike = false,
|
|
13
|
+
isTsx = false
|
|
14
|
+
} = {}) => ({
|
|
11
15
|
/**
|
|
12
16
|
* Require consistent naming conventions.
|
|
13
17
|
*
|
|
@@ -19,7 +23,10 @@ export const getTypescriptNamingConventionRule = ({ isTsx = false } = {}) => ({
|
|
|
19
23
|
"error",
|
|
20
24
|
// enforce that unused variable-likes are prefixed with `_`
|
|
21
25
|
{
|
|
22
|
-
format: [
|
|
26
|
+
format: [
|
|
27
|
+
"camelCase",
|
|
28
|
+
(isComponentLike || isTsx) && "StrictPascalCase"
|
|
29
|
+
].filter(Boolean),
|
|
23
30
|
leadingUnderscore: "require",
|
|
24
31
|
modifiers: ["unused"],
|
|
25
32
|
selector: "variableLike",
|
|
@@ -27,7 +34,10 @@ export const getTypescriptNamingConventionRule = ({ isTsx = false } = {}) => ({
|
|
|
27
34
|
},
|
|
28
35
|
// enforce that everything is camelCase by default
|
|
29
36
|
{
|
|
30
|
-
format: [
|
|
37
|
+
format: [
|
|
38
|
+
"camelCase",
|
|
39
|
+
(isComponentLike || isTsx) && "StrictPascalCase"
|
|
40
|
+
].filter(Boolean),
|
|
31
41
|
leadingUnderscore: "forbid",
|
|
32
42
|
selector: "default",
|
|
33
43
|
trailingUnderscore: "forbid"
|