@dextinity/eslint-config 2.0.0-canary-20260729062014
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/CHANGELOG.md +1098 -0
- package/LICENSE +24 -0
- package/core.js +127 -0
- package/eslint.config.mjs +68 -0
- package/future/nestjs.js +2 -0
- package/future/nextjs.js +2 -0
- package/future/react.js +2 -0
- package/lint-staged.config.mjs +8 -0
- package/nestjs.js +43 -0
- package/nextjs.js +106 -0
- package/package.json +86 -0
- package/react.js +192 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Vivid Planet Software GmbH
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/core.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import prettierConfig from "eslint-config-prettier";
|
|
5
|
+
import prettierPlugin from "eslint-plugin-prettier/recommended";
|
|
6
|
+
import unusedImports from "eslint-plugin-unused-imports";
|
|
7
|
+
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
|
8
|
+
import { configs as eslintPluginJsonc } from "eslint-plugin-jsonc";
|
|
9
|
+
import cometPlugin from "@dextinity/eslint-plugin";
|
|
10
|
+
import importPlugin from "eslint-plugin-import";
|
|
11
|
+
import js from "@eslint/js";
|
|
12
|
+
import packageJson from "eslint-plugin-package-json";
|
|
13
|
+
|
|
14
|
+
export const restrictedImportPatterns = [
|
|
15
|
+
{
|
|
16
|
+
group: ["@dextinity/*/lib", "@dextinity/*/lib/**"],
|
|
17
|
+
message: "Don't import private files from @dextinity packages via /lib. Use the package root instead.",
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
/** @type {import('eslint')} */
|
|
22
|
+
const config = [
|
|
23
|
+
js.configs.recommended,
|
|
24
|
+
eslint.configs.recommended,
|
|
25
|
+
...tseslint.configs.recommended,
|
|
26
|
+
{
|
|
27
|
+
...prettierConfig,
|
|
28
|
+
files: ["*.ts", "*.tsx", "*.json"],
|
|
29
|
+
},
|
|
30
|
+
prettierPlugin,
|
|
31
|
+
{
|
|
32
|
+
plugins: {
|
|
33
|
+
"unused-imports": unusedImports,
|
|
34
|
+
},
|
|
35
|
+
rules: {
|
|
36
|
+
"unused-imports/no-unused-imports": "error",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
plugins: {
|
|
41
|
+
"simple-import-sort": simpleImportSort,
|
|
42
|
+
},
|
|
43
|
+
rules: {
|
|
44
|
+
"simple-import-sort/imports": "error",
|
|
45
|
+
"simple-import-sort/exports": "error",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
plugins: {
|
|
50
|
+
"@dextinity": cometPlugin,
|
|
51
|
+
},
|
|
52
|
+
rules: {
|
|
53
|
+
"@dextinity/no-other-module-relative-import": ["warn"],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
...importPlugin.flatConfigs.recommended,
|
|
58
|
+
rules: {
|
|
59
|
+
"import/no-duplicates": ["error", { "prefer-inline": true }],
|
|
60
|
+
"import/newline-after-import": "error",
|
|
61
|
+
"import/no-extraneous-dependencies": "error",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
...eslintPluginJsonc["flat/recommended-with-json"],
|
|
65
|
+
{
|
|
66
|
+
ignores: [
|
|
67
|
+
/**
|
|
68
|
+
* disable package.json and nested package.json files (e.g.in admin -> /server/package.json)
|
|
69
|
+
*/
|
|
70
|
+
"**/package.json",
|
|
71
|
+
],
|
|
72
|
+
rules: {
|
|
73
|
+
"jsonc/sort-keys": "error",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
...packageJson.configs.recommended,
|
|
78
|
+
rules: {
|
|
79
|
+
...packageJson.configs.recommended.rules,
|
|
80
|
+
"package-json/require-type": "off",
|
|
81
|
+
"package-json/require-description": "off",
|
|
82
|
+
"package-json/require-attribution": "off",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
ignores: ["**/*.json"],
|
|
87
|
+
languageOptions: {
|
|
88
|
+
globals: {
|
|
89
|
+
...globals.node,
|
|
90
|
+
...globals.jest,
|
|
91
|
+
},
|
|
92
|
+
parser: tseslint.parser,
|
|
93
|
+
parserOptions: {
|
|
94
|
+
projectService: true,
|
|
95
|
+
tsconfigRootDir: import.meta.dirname,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
rules: {
|
|
99
|
+
"no-unused-vars": "off",
|
|
100
|
+
"prefer-template": "error",
|
|
101
|
+
"no-console": ["error", { allow: ["warn", "error", "info", "debug"] }],
|
|
102
|
+
curly: "error",
|
|
103
|
+
"no-return-await": "error",
|
|
104
|
+
"no-restricted-imports": [
|
|
105
|
+
"error",
|
|
106
|
+
{
|
|
107
|
+
patterns: restrictedImportPatterns,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
"@typescript-eslint/no-unused-vars": ["error", { args: "none", ignoreRestSiblings: true }],
|
|
111
|
+
"@typescript-eslint/no-inferrable-types": ["error", { ignoreProperties: true }],
|
|
112
|
+
"@typescript-eslint/prefer-enum-initializers": "error",
|
|
113
|
+
"@typescript-eslint/no-non-null-assertion": "error",
|
|
114
|
+
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
115
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
116
|
+
"error",
|
|
117
|
+
{
|
|
118
|
+
prefer: "type-imports",
|
|
119
|
+
disallowTypeAnnotations: false,
|
|
120
|
+
fixStyle: "inline-type-imports",
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
export default config;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
|
+
import eslint from "@eslint/js";
|
|
3
|
+
import globals from "globals";
|
|
4
|
+
import tseslint from "typescript-eslint";
|
|
5
|
+
import prettierConfig from "eslint-config-prettier";
|
|
6
|
+
import prettierPlugin from "eslint-plugin-prettier/recommended";
|
|
7
|
+
import unusedImports from "eslint-plugin-unused-imports";
|
|
8
|
+
import simpleImportSort from "eslint-plugin-simple-import-sort";
|
|
9
|
+
import { configs as eslintPluginJsonc } from "eslint-plugin-jsonc";
|
|
10
|
+
import packageJson from "eslint-plugin-package-json";
|
|
11
|
+
|
|
12
|
+
export default defineConfig([
|
|
13
|
+
eslint.configs.recommended,
|
|
14
|
+
...tseslint.configs.recommended,
|
|
15
|
+
prettierConfig,
|
|
16
|
+
prettierPlugin,
|
|
17
|
+
{
|
|
18
|
+
plugins: {
|
|
19
|
+
"unused-imports": unusedImports,
|
|
20
|
+
},
|
|
21
|
+
rules: {
|
|
22
|
+
"unused-imports/no-unused-imports": "error",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
plugins: {
|
|
27
|
+
"simple-import-sort": simpleImportSort,
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
"simple-import-sort/imports": "error",
|
|
31
|
+
"simple-import-sort/exports": "error",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
languageOptions: {
|
|
36
|
+
globals: {
|
|
37
|
+
...globals.node,
|
|
38
|
+
...globals.jest,
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
parser: tseslint.parser,
|
|
42
|
+
parserOptions: {
|
|
43
|
+
projectService: true,
|
|
44
|
+
tsconfigRootDir: import.meta.dirname,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
// Rules
|
|
48
|
+
rules: {
|
|
49
|
+
"prefer-template": "error",
|
|
50
|
+
"no-console": ["error", { allow: ["warn", "error", "info", "debug"] }],
|
|
51
|
+
"no-return-await": "error",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
/* order matters -> json rules must be after typescript rules*/
|
|
55
|
+
...eslintPluginJsonc["flat/recommended-with-json"],
|
|
56
|
+
{
|
|
57
|
+
ignores: ["package.json"],
|
|
58
|
+
rules: {
|
|
59
|
+
"jsonc/sort-keys": "error",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
...packageJson.configs.recommended,
|
|
64
|
+
rules: {
|
|
65
|
+
"package-json/require-attribution": "off",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
]);
|
package/future/nestjs.js
ADDED
package/future/nextjs.js
ADDED
package/future/react.js
ADDED
package/nestjs.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import coreConfig, { restrictedImportPatterns } from "./core.js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
|
|
4
|
+
export const restrictedImportPaths = [
|
|
5
|
+
{
|
|
6
|
+
name: "node-cache",
|
|
7
|
+
message: "node-cache is abandonware. Use @nestjs/cache-manager instead",
|
|
8
|
+
},
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
/** @type {import('eslint')} */
|
|
12
|
+
const config = [
|
|
13
|
+
...coreConfig,
|
|
14
|
+
{
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: {
|
|
17
|
+
...globals.node,
|
|
18
|
+
...globals.jest,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
rules: {
|
|
22
|
+
"import/no-extraneous-dependencies": [
|
|
23
|
+
"error",
|
|
24
|
+
{
|
|
25
|
+
devDependencies: ["**/*.spec.ts", "**/*.test.ts"],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
"import/order": "off",
|
|
29
|
+
"no-console": "off",
|
|
30
|
+
"no-duplicate-imports": "error",
|
|
31
|
+
"sort-imports": "off",
|
|
32
|
+
"no-restricted-imports": [
|
|
33
|
+
"error",
|
|
34
|
+
{
|
|
35
|
+
paths: restrictedImportPaths,
|
|
36
|
+
patterns: restrictedImportPatterns,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
export default config;
|
package/nextjs.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import coreConfig, { restrictedImportPatterns } from "./core.js";
|
|
2
|
+
import graphqlPlugin from "@graphql-eslint/eslint-plugin";
|
|
3
|
+
import react from "eslint-plugin-react";
|
|
4
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
5
|
+
import globals from "globals";
|
|
6
|
+
import nextPlugin from "@next/eslint-plugin-next";
|
|
7
|
+
|
|
8
|
+
export const restrictedImportPaths = [
|
|
9
|
+
{
|
|
10
|
+
name: "react",
|
|
11
|
+
importNames: ["default"],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "next/image",
|
|
15
|
+
importNames: ["default"],
|
|
16
|
+
message: "Don't use next/image. See https://docs.comet-dxp.com/docs/faqs/next-image-import-restriction",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "node-cache",
|
|
20
|
+
message: "node-cache is abandonware. Use cache-manager or @cacheable/node-cache instead",
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/** @type {import('eslint')} */
|
|
25
|
+
const config = [
|
|
26
|
+
...coreConfig,
|
|
27
|
+
// Extend config from plugin instead of using eslint-config-next to prevent issues with duplicate plugins, e.g., import.
|
|
28
|
+
// See https://nextjs.org/docs/app/api-reference/config/eslint#migrating-existing-config.
|
|
29
|
+
nextPlugin.configs["core-web-vitals"],
|
|
30
|
+
{
|
|
31
|
+
rules: {
|
|
32
|
+
"@dextinity/no-private-sibling-import": ["error", ["gql", "sc", "gql.generated"]],
|
|
33
|
+
"no-restricted-globals": ["error", "React"],
|
|
34
|
+
"no-restricted-imports": [
|
|
35
|
+
"error",
|
|
36
|
+
{
|
|
37
|
+
paths: restrictedImportPaths,
|
|
38
|
+
patterns: restrictedImportPatterns,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
languageOptions: {
|
|
45
|
+
parserOptions: {
|
|
46
|
+
ecmaFeatures: {
|
|
47
|
+
jsx: true,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
globals: {
|
|
51
|
+
...globals.browser,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
plugins: {
|
|
55
|
+
react: react,
|
|
56
|
+
"react-hooks": reactHooks,
|
|
57
|
+
},
|
|
58
|
+
settings: {
|
|
59
|
+
react: {
|
|
60
|
+
version: "detect",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
rules: {
|
|
64
|
+
...react.configs.recommended.rules,
|
|
65
|
+
...reactHooks.configs.recommended.rules,
|
|
66
|
+
"react/display-name": "off",
|
|
67
|
+
"react/jsx-curly-brace-presence": "error",
|
|
68
|
+
"react/prop-types": "off",
|
|
69
|
+
"react/self-closing-comp": "error",
|
|
70
|
+
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
|
|
71
|
+
"react/react-in-jsx-scope": "off",
|
|
72
|
+
"@next/next/no-img-element": "off",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
files: ["**/*.{ts,tsx,js,jsx}"],
|
|
77
|
+
processor: graphqlPlugin.processor,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
files: ["**/*.graphql"],
|
|
81
|
+
languageOptions: {
|
|
82
|
+
parser: graphqlPlugin.parser,
|
|
83
|
+
},
|
|
84
|
+
plugins: {
|
|
85
|
+
"@graphql-eslint": graphqlPlugin,
|
|
86
|
+
},
|
|
87
|
+
rules: {
|
|
88
|
+
// Type-info rules from typescript-eslint cannot run on virtual GraphQL blocks extracted by the processor.
|
|
89
|
+
"@typescript-eslint/consistent-type-imports": "off",
|
|
90
|
+
"@typescript-eslint/consistent-type-exports": "off",
|
|
91
|
+
"@graphql-eslint/naming-convention": [
|
|
92
|
+
"error",
|
|
93
|
+
{
|
|
94
|
+
OperationDefinition: {
|
|
95
|
+
forbiddenSuffixes: ["Query", "Mutation", "Subscription"],
|
|
96
|
+
},
|
|
97
|
+
FragmentDefinition: {
|
|
98
|
+
forbiddenSuffixes: ["Fragment"],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
export default config;
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dextinity/eslint-config",
|
|
3
|
+
"version": "2.0.0-canary-20260729062014",
|
|
4
|
+
"description": "A set of ESLint configurations for Comet projects",
|
|
5
|
+
"repository": {
|
|
6
|
+
"directory": "packages/eslint-config",
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/vivid-planet/comet"
|
|
9
|
+
},
|
|
10
|
+
"license": "BSD-2-Clause",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./core.js": {
|
|
14
|
+
"import": "./core.js"
|
|
15
|
+
},
|
|
16
|
+
"./future/nestjs.js": {
|
|
17
|
+
"import": "./future/nestjs.js"
|
|
18
|
+
},
|
|
19
|
+
"./future/nextjs.js": {
|
|
20
|
+
"import": "./future/nextjs.js"
|
|
21
|
+
},
|
|
22
|
+
"./future/react.js": {
|
|
23
|
+
"import": "./future/react.js"
|
|
24
|
+
},
|
|
25
|
+
"./nestjs.js": {
|
|
26
|
+
"import": "./nestjs.js"
|
|
27
|
+
},
|
|
28
|
+
"./nextjs.js": {
|
|
29
|
+
"import": "./nextjs.js"
|
|
30
|
+
},
|
|
31
|
+
"./react.js": {
|
|
32
|
+
"import": "./react.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@calm/eslint-plugin-react-intl": "^1.4.1",
|
|
37
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
38
|
+
"@eslint/js": "^9.39.4",
|
|
39
|
+
"@graphql-eslint/eslint-plugin": "^4.4.0",
|
|
40
|
+
"@next/eslint-plugin-next": "^16.2.10",
|
|
41
|
+
"eslint-config-prettier": "^10.1.8",
|
|
42
|
+
"eslint-plugin-formatjs": "^5.4.2",
|
|
43
|
+
"eslint-plugin-import": "^2.32.0",
|
|
44
|
+
"eslint-plugin-jsonc": "^2.21.1",
|
|
45
|
+
"eslint-plugin-package-json": "^0.91.2",
|
|
46
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
47
|
+
"eslint-plugin-react": "^7.37.5",
|
|
48
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
49
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
50
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
51
|
+
"globals": "^15.15.0",
|
|
52
|
+
"npm-run-all2": "^8.0.4",
|
|
53
|
+
"typescript-eslint": "^8.62.1",
|
|
54
|
+
"@dextinity/eslint-plugin": "2.0.0-canary-20260729062014"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"eslint": "^9.39.4",
|
|
58
|
+
"prettier": "^3.6.2",
|
|
59
|
+
"typescript": "^5.9.3"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"eslint": ">=9",
|
|
63
|
+
"prettier": ">=3"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"next": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=22.0.0"
|
|
72
|
+
},
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"access": "public",
|
|
75
|
+
"registry": "https://registry.npmjs.org"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"lint": "run-p lint:prettier lint:eslint",
|
|
79
|
+
"lint:ci": "pnpm run lint",
|
|
80
|
+
"lint:eslint": "eslint --max-warnings 0 '**/*.json' --no-warn-ignored",
|
|
81
|
+
"lint:fix": "run-p lint:fix:eslint lint:fix:prettier",
|
|
82
|
+
"lint:fix:eslint": "pnpm run lint:eslint --fix",
|
|
83
|
+
"lint:fix:prettier": "pnpm run lint:prettier --write",
|
|
84
|
+
"lint:prettier": "pnpm exec prettier --check '*.{ts,js,json,md,yml,yaml}'"
|
|
85
|
+
}
|
|
86
|
+
}
|
package/react.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import coreConfig, { restrictedImportPatterns } from "./core.js";
|
|
2
|
+
import reactIntlFormatPlugin from "@calm/eslint-plugin-react-intl";
|
|
3
|
+
import globals from "globals";
|
|
4
|
+
import formatJs from "eslint-plugin-formatjs";
|
|
5
|
+
import graphqlPlugin from "@graphql-eslint/eslint-plugin";
|
|
6
|
+
import react from "eslint-plugin-react";
|
|
7
|
+
import cometPlugin from "@dextinity/eslint-plugin";
|
|
8
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
9
|
+
|
|
10
|
+
const cometAdminImportsRestrictedFromMuiMaterial = ["Alert", "Button", "Dialog", "Tooltip"];
|
|
11
|
+
|
|
12
|
+
export const restrictedImportPaths = [
|
|
13
|
+
...cometAdminImportsRestrictedFromMuiMaterial.map((name) => ({
|
|
14
|
+
name: "@mui/material",
|
|
15
|
+
importNames: [name],
|
|
16
|
+
message: `Please use ${name} from @dextinity/admin instead`,
|
|
17
|
+
})),
|
|
18
|
+
...cometAdminImportsRestrictedFromMuiMaterial.map((name) => ({
|
|
19
|
+
name: `@mui/material/${name}`,
|
|
20
|
+
message: `Please use ${name} from @dextinity/admin instead`,
|
|
21
|
+
})),
|
|
22
|
+
{
|
|
23
|
+
name: "react",
|
|
24
|
+
importNames: ["default"],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "@mui/material",
|
|
28
|
+
importNames: ["styled"],
|
|
29
|
+
message: "Please use styled from @mui/material/styles instead.",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "@mui/icons-material",
|
|
33
|
+
message: "Please use @dextinity/admin-icons instead",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "@mui/x-data-grid",
|
|
37
|
+
importNames: ["GridColDef"],
|
|
38
|
+
message: "Please use GridColDef from @dextinity/admin instead",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "@mui/x-data-grid-pro",
|
|
42
|
+
importNames: ["GridColDef"],
|
|
43
|
+
message: "Please use GridColDef from @dextinity/admin instead",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "@mui/x-data-grid-premium",
|
|
47
|
+
importNames: ["GridColDef"],
|
|
48
|
+
message: "Please use GridColDef from @dextinity/admin instead",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "@mui/x-data-grid",
|
|
52
|
+
importNames: ["GridToolbarQuickFilter"],
|
|
53
|
+
message: "Please use GridToolbarQuickFilter from @dextinity/admin instead",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "@mui/x-data-grid-pro",
|
|
57
|
+
importNames: ["GridToolbarQuickFilter"],
|
|
58
|
+
message: "Please use GridToolbarQuickFilter from @dextinity/admin instead",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "@mui/x-data-grid-premium",
|
|
62
|
+
importNames: ["GridToolbarQuickFilter"],
|
|
63
|
+
message: "Please use GridToolbarQuickFilter from @dextinity/admin instead",
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
/** @type {import('eslint')} */
|
|
68
|
+
const config = [
|
|
69
|
+
...coreConfig,
|
|
70
|
+
{
|
|
71
|
+
plugins: {
|
|
72
|
+
"@calm/react-intl": reactIntlFormatPlugin,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
plugins: {
|
|
77
|
+
formatjs: formatJs,
|
|
78
|
+
},
|
|
79
|
+
rules: {
|
|
80
|
+
"formatjs/enforce-default-message": ["error", "literal"],
|
|
81
|
+
"formatjs/enforce-placeholders": "error",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
86
|
+
rules: {
|
|
87
|
+
"@calm/react-intl/missing-formatted-message": ["error", { enforceLabels: true }],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
92
|
+
ignores: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"],
|
|
93
|
+
rules: {
|
|
94
|
+
"react/jsx-no-literals": [
|
|
95
|
+
"error",
|
|
96
|
+
{
|
|
97
|
+
allowedStrings: ["…", "€", "$", "?", "–", "—", "/", "(", ")", "%"],
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
"@typescript-eslint/consistent-type-exports": [
|
|
101
|
+
"error",
|
|
102
|
+
{
|
|
103
|
+
fixMixedExportsWithInlineTypeSpecifier: true,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
files: ["**/*.{ts,tsx}"],
|
|
110
|
+
plugins: {
|
|
111
|
+
"react-hooks": reactHooks,
|
|
112
|
+
},
|
|
113
|
+
rules: {
|
|
114
|
+
"react-hooks/rules-of-hooks": "error",
|
|
115
|
+
"react-hooks/exhaustive-deps": "error",
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
languageOptions: {
|
|
120
|
+
parserOptions: {
|
|
121
|
+
ecmaFeatures: {
|
|
122
|
+
jsx: true,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
globals: {
|
|
126
|
+
...globals.browser,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
plugins: {
|
|
130
|
+
react: react,
|
|
131
|
+
},
|
|
132
|
+
settings: {
|
|
133
|
+
react: {
|
|
134
|
+
version: "detect",
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
rules: {
|
|
138
|
+
"react/self-closing-comp": "error",
|
|
139
|
+
"react/display-name": "off",
|
|
140
|
+
"react/prop-types": "off",
|
|
141
|
+
"react/jsx-curly-brace-presence": "error",
|
|
142
|
+
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
|
|
143
|
+
"no-restricted-globals": ["error", "React"],
|
|
144
|
+
"no-restricted-imports": [
|
|
145
|
+
"error",
|
|
146
|
+
{
|
|
147
|
+
paths: restrictedImportPaths,
|
|
148
|
+
patterns: restrictedImportPatterns,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
plugins: {
|
|
155
|
+
"@dextinity": cometPlugin,
|
|
156
|
+
},
|
|
157
|
+
rules: {
|
|
158
|
+
"@dextinity/no-private-sibling-import": "error",
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
files: ["**/*.{ts,tsx,js,jsx}"],
|
|
163
|
+
processor: graphqlPlugin.processor,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
files: ["**/*.graphql"],
|
|
167
|
+
languageOptions: {
|
|
168
|
+
parser: graphqlPlugin.parser,
|
|
169
|
+
},
|
|
170
|
+
plugins: {
|
|
171
|
+
"@graphql-eslint": graphqlPlugin,
|
|
172
|
+
},
|
|
173
|
+
rules: {
|
|
174
|
+
// Type-info rules from typescript-eslint cannot run on virtual GraphQL blocks extracted by the processor.
|
|
175
|
+
"@typescript-eslint/consistent-type-imports": "off",
|
|
176
|
+
"@typescript-eslint/consistent-type-exports": "off",
|
|
177
|
+
"@graphql-eslint/naming-convention": [
|
|
178
|
+
"error",
|
|
179
|
+
{
|
|
180
|
+
OperationDefinition: {
|
|
181
|
+
forbiddenSuffixes: ["Query", "Mutation", "Subscription"],
|
|
182
|
+
},
|
|
183
|
+
FragmentDefinition: {
|
|
184
|
+
forbiddenSuffixes: ["Fragment"],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
export default config;
|