@elliemae/pui-cli 9.0.0-alpha.1 → 9.0.0-alpha.2
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/README.md +33 -0
- package/dist/cjs/commands/test.js +0 -1
- package/dist/cjs/commands/utils.js +4 -4
- package/dist/cjs/commands/vitest.js +0 -1
- package/dist/cjs/index.cjs +12 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/lint-config/eslint/common.cjs +1 -1
- package/dist/cjs/lint-config/eslint/flat/common.mjs +167 -0
- package/dist/cjs/lint-config/eslint/flat/index.mjs +20 -0
- package/dist/cjs/lint-config/eslint/flat/non-react-export.mjs +10 -0
- package/dist/cjs/lint-config/eslint/flat/non-react.mjs +6 -0
- package/dist/cjs/lint-config/eslint/flat/presets.mjs +78 -0
- package/dist/cjs/lint-config/eslint/flat/react-export.mjs +7 -0
- package/dist/cjs/lint-config/eslint/flat/react.mjs +60 -0
- package/dist/cjs/lint-config/eslint/flat/rules.mjs +185 -0
- package/dist/cjs/lint-config/eslint/typescript/non-react.cjs +1 -1
- package/dist/cjs/lint-config/eslint/typescript/react.cjs +1 -1
- package/dist/cjs/monorepo/utils.cjs +2 -2
- package/dist/cjs/monorepo/utils.js +1 -1
- package/dist/cjs/testing/jest.config.cjs +4 -4
- package/dist/cjs/testing/resolver.cjs +1 -1
- package/dist/cjs/testing/setup-react-env.js +1 -1
- package/dist/cjs/transpile/esbuild.js +1 -1
- package/dist/cjs/webpack/csp-plugin.js +2 -4
- package/dist/cjs/webpack/prop-types-shim.js +0 -1
- package/dist/cjs/webpack/webpack.lib.base.babel.js +0 -8
- package/dist/esm/commands/test.js +0 -1
- package/dist/esm/commands/utils.js +4 -4
- package/dist/esm/commands/vitest.js +0 -1
- package/dist/esm/index.cjs +12 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/lint-config/eslint/common.cjs +1 -1
- package/dist/esm/lint-config/eslint/flat/common.mjs +167 -0
- package/dist/esm/lint-config/eslint/flat/index.mjs +20 -0
- package/dist/esm/lint-config/eslint/flat/non-react-export.mjs +10 -0
- package/dist/esm/lint-config/eslint/flat/non-react.mjs +6 -0
- package/dist/esm/lint-config/eslint/flat/presets.mjs +78 -0
- package/dist/esm/lint-config/eslint/flat/react-export.mjs +7 -0
- package/dist/esm/lint-config/eslint/flat/react.mjs +60 -0
- package/dist/esm/lint-config/eslint/flat/rules.mjs +185 -0
- package/dist/esm/lint-config/eslint/typescript/non-react.cjs +1 -1
- package/dist/esm/lint-config/eslint/typescript/react.cjs +1 -1
- package/dist/esm/monorepo/utils.cjs +2 -2
- package/dist/esm/monorepo/utils.js +1 -1
- package/dist/esm/testing/jest.config.cjs +4 -4
- package/dist/esm/testing/resolver.cjs +1 -1
- package/dist/esm/testing/setup-react-env.js +1 -1
- package/dist/esm/transpile/esbuild.js +1 -1
- package/dist/esm/webpack/csp-plugin.js +2 -4
- package/dist/esm/webpack/prop-types-shim.js +0 -1
- package/dist/esm/webpack/webpack.lib.base.babel.js +0 -8
- package/dist/types/lib/commands/build.d.ts +1 -1
- package/dist/types/lib/commands/buildcdn.d.ts +1 -1
- package/dist/types/lib/commands/codemod.d.ts +1 -1
- package/dist/types/lib/commands/gendoc.d.ts +1 -1
- package/dist/types/lib/commands/lint.d.ts +1 -1
- package/dist/types/lib/commands/pack.d.ts +1 -1
- package/dist/types/lib/commands/start.d.ts +1 -1
- package/dist/types/lib/commands/storybook.d.ts +1 -1
- package/dist/types/lib/commands/test.d.ts +1 -1
- package/dist/types/lib/commands/tscheck.d.ts +1 -1
- package/dist/types/lib/commands/version.d.ts +1 -1
- package/dist/types/lib/commands/vitest.d.ts +1 -1
- package/dist/types/lib/index.d.cts +5 -1
- package/dist/types/lib/index.d.ts +4 -0
- package/dist/types/lib/lint-config/eslint/flat/common.d.mts +6 -0
- package/dist/types/lib/lint-config/eslint/flat/index.d.mts +6 -0
- package/dist/types/lib/lint-config/eslint/flat/non-react-export.d.mts +4 -0
- package/dist/types/lib/lint-config/eslint/flat/non-react.d.mts +3 -0
- package/dist/types/lib/lint-config/eslint/flat/presets.d.mts +63 -0
- package/dist/types/lib/lint-config/eslint/flat/react-export.d.mts +4 -0
- package/dist/types/lib/lint-config/eslint/flat/react.d.mts +4 -0
- package/dist/types/lib/lint-config/eslint/flat/rules.d.mts +358 -0
- package/dist/types/lib/server/appRoutes.d.ts +1 -1
- package/dist/types/lib/server/csp.d.ts +1 -1
- package/dist/types/lib/server/middlewares.d.ts +1 -1
- package/dist/types/lib/webpack/csp-plugin.d.ts +3 -3
- package/dist/types/lib/webpack/helpers.d.ts +1 -1
- package/dist/types/lib/webpack/interceptor-middleware.d.ts +2 -2
- package/dist/types/lib/webpack/webpack.base.babel.d.ts +1 -1
- package/dist/types/lib/webpack/webpack.lib.base.babel.d.ts +1 -1
- package/dist/types/lib/webpack/webpack.lib.prod.babel.d.ts +1 -1
- package/dist/types/lib/webpack/webpack.prod.babel.d.ts +1 -1
- package/dist/types/lib/webpack/webpack.storybook.d.ts +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/lib/lint-config/commitlint.config.cjs +1 -0
- package/lib/lint-config/eslint/common.cjs +164 -0
- package/lib/lint-config/eslint/flat/common.mjs +167 -0
- package/lib/lint-config/eslint/flat/index.mjs +20 -0
- package/lib/lint-config/eslint/flat/non-react-export.mjs +10 -0
- package/lib/lint-config/eslint/flat/non-react.mjs +6 -0
- package/lib/lint-config/eslint/flat/presets.mjs +78 -0
- package/lib/lint-config/eslint/flat/react-export.mjs +7 -0
- package/lib/lint-config/eslint/flat/react.mjs +60 -0
- package/lib/lint-config/eslint/flat/rules.mjs +185 -0
- package/lib/lint-config/eslint/non-react.cjs +14 -0
- package/lib/lint-config/eslint/react.cjs +26 -0
- package/lib/lint-config/eslint/typescript/common.cjs +49 -0
- package/lib/lint-config/eslint/typescript/non-react.cjs +12 -0
- package/lib/lint-config/eslint/typescript/react.cjs +19 -0
- package/lib/lint-config/lint-staged.config.js +15 -0
- package/lib/lint-config/prettier.config.cjs +8 -0
- package/lib/lint-config/stylelint.config.cjs +19 -0
- package/package.json +21 -22
|
@@ -6,13 +6,13 @@ const WORKSPACE_MANIFEST_FILENAME = 'pnpm-workspace.yaml';
|
|
|
6
6
|
|
|
7
7
|
const getPNPMWorkspaceLocation = (cwd) => {
|
|
8
8
|
let location = null;
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
for (const fileName of [WORKSPACE_MANIFEST_FILENAME, 'pnpm-workspace.yml']) {
|
|
11
11
|
try {
|
|
12
12
|
const result = execSync(`npx find-up ${fileName}`, { cwd });
|
|
13
13
|
location = result.toString().trim();
|
|
14
14
|
break;
|
|
15
|
-
} catch
|
|
15
|
+
} catch {
|
|
16
16
|
// ignore
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -6,11 +6,11 @@ const { findMonoRepoRoot } = require('../monorepo/utils.cjs');
|
|
|
6
6
|
|
|
7
7
|
let isReactModule = true;
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
require('react');
|
|
11
11
|
require('styled-components');
|
|
12
|
-
|
|
13
|
-
} catch
|
|
12
|
+
|
|
13
|
+
} catch {
|
|
14
14
|
isReactModule = false;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -89,7 +89,7 @@ const jestConfig = {
|
|
|
89
89
|
'^.+\\.[jt]sx?$': ['@swc/jest', swcrcConfig],
|
|
90
90
|
},
|
|
91
91
|
transformIgnorePatterns: [
|
|
92
|
-
// eslint-disable-next-line
|
|
92
|
+
// eslint-disable-next-line no-useless-escape
|
|
93
93
|
'/node_modules/(?!(\@elliemae\/pui-cli|lodash-es|react-select|react-dates|d3|internmap|delaunator|robust-predicates))/',
|
|
94
94
|
],
|
|
95
95
|
globals: {
|
|
@@ -32,7 +32,7 @@ module.exports = (request, options) => {
|
|
|
32
32
|
}
|
|
33
33
|
const resolution = resolutions.find(({ matcher }) => matcher.test(request));
|
|
34
34
|
if (resolution) {
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
for (const extension of resolution.extensions) {
|
|
37
37
|
try {
|
|
38
38
|
return resolver(
|
|
@@ -65,7 +65,7 @@ const copyFiles = async ({ srcdir, outdir }) => {
|
|
|
65
65
|
const files = await (0, import_fast_glob.default)([
|
|
66
66
|
`${srcdir}/**/*.*`,
|
|
67
67
|
`${srcdir}/**/.swcrc`,
|
|
68
|
-
`!${srcdir}/**/*.{js,jsx,ts,tsx
|
|
68
|
+
`!${srcdir}/**/*.{js,jsx,ts,tsx}`
|
|
69
69
|
]);
|
|
70
70
|
await Promise.all(
|
|
71
71
|
files.map(async (srcFilePath) => {
|
|
@@ -38,14 +38,12 @@ const defaultOptions = {
|
|
|
38
38
|
};
|
|
39
39
|
class CspPlugin {
|
|
40
40
|
#options = defaultOptions;
|
|
41
|
-
#htmlWebpackPlugin;
|
|
42
41
|
/**
|
|
43
42
|
*
|
|
44
|
-
* @param
|
|
43
|
+
* @param _htmlWebpackPlugin
|
|
45
44
|
* @param {object} options Additional options for this module.
|
|
46
45
|
*/
|
|
47
|
-
constructor(
|
|
48
|
-
this.#htmlWebpackPlugin = htmlWebpackPlugin;
|
|
46
|
+
constructor(_htmlWebpackPlugin, options) {
|
|
49
47
|
this.#options = { ...this.#options, ...options ?? {} };
|
|
50
48
|
}
|
|
51
49
|
/**
|
|
@@ -48,7 +48,6 @@ const shim = function noop() {
|
|
|
48
48
|
shim.isRequired = shim;
|
|
49
49
|
const createPropTypes = () => {
|
|
50
50
|
const handler = {
|
|
51
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
52
51
|
get(_target, prop) {
|
|
53
52
|
if (prop === "__esModule") return true;
|
|
54
53
|
if (prop === "default") return pt;
|
|
@@ -68,13 +68,11 @@ const plugins = [
|
|
|
68
68
|
new import_webpack.default.DefinePlugin({
|
|
69
69
|
APP_CONFIG: (0, import_utils.getAppConfig)()
|
|
70
70
|
}),
|
|
71
|
-
/* eslint-disable indent */
|
|
72
71
|
...copyPluginPatterns.length > 0 ? [
|
|
73
72
|
new import_copy_webpack_plugin.default({
|
|
74
73
|
patterns: copyPluginPatterns
|
|
75
74
|
})
|
|
76
75
|
] : [],
|
|
77
|
-
/* eslint-enable indent */
|
|
78
76
|
new import_webpack.default.optimize.LimitChunkCountPlugin({
|
|
79
77
|
maxChunks: 1
|
|
80
78
|
}),
|
|
@@ -96,7 +94,6 @@ const baseConfig = (options) => ({
|
|
|
96
94
|
// Merge with env dependent settings
|
|
97
95
|
optimization: options.optimization,
|
|
98
96
|
module: {
|
|
99
|
-
/* eslint-disable indent */
|
|
100
97
|
...process.env.KEEP_IMPORT_META === "true" ? {
|
|
101
98
|
parser: {
|
|
102
99
|
javascript: {
|
|
@@ -104,7 +101,6 @@ const baseConfig = (options) => ({
|
|
|
104
101
|
}
|
|
105
102
|
}
|
|
106
103
|
} : {},
|
|
107
|
-
/* eslint-enable indent */
|
|
108
104
|
rules: [
|
|
109
105
|
{
|
|
110
106
|
test: /^(?!.*\.exec\.js$).*\.jsx?$/,
|
|
@@ -117,13 +113,11 @@ const baseConfig = (options) => ({
|
|
|
117
113
|
loader: "esbuild-loader",
|
|
118
114
|
options: {
|
|
119
115
|
target: (0, import_browserslist_to_esbuild.default)(),
|
|
120
|
-
/* eslint-disable indent */
|
|
121
116
|
...process.env.KEEP_IMPORT_META === "true" ? {
|
|
122
117
|
supported: {
|
|
123
118
|
"import-meta": true
|
|
124
119
|
}
|
|
125
120
|
} : {}
|
|
126
|
-
/* eslint-enable indent */
|
|
127
121
|
}
|
|
128
122
|
}
|
|
129
123
|
},
|
|
@@ -138,13 +132,11 @@ const baseConfig = (options) => ({
|
|
|
138
132
|
loader: "esbuild-loader",
|
|
139
133
|
options: {
|
|
140
134
|
target: (0, import_browserslist_to_esbuild.default)(),
|
|
141
|
-
/* eslint-disable indent */
|
|
142
135
|
...process.env.KEEP_IMPORT_META === "true" ? {
|
|
143
136
|
supported: {
|
|
144
137
|
"import-meta": true
|
|
145
138
|
}
|
|
146
139
|
} : {}
|
|
147
|
-
/* eslint-enable indent */
|
|
148
140
|
}
|
|
149
141
|
}
|
|
150
142
|
},
|
|
@@ -41,7 +41,7 @@ const readPackageLock = async () => {
|
|
|
41
41
|
const pkgLockJSON = await readFile(appPkgLockFile, "utf8");
|
|
42
42
|
const { dependencies } = JSON.parse(pkgLockJSON);
|
|
43
43
|
return (moduleName) => dependencies[moduleName]?.version || "";
|
|
44
|
-
} catch
|
|
44
|
+
} catch {
|
|
45
45
|
console.warn("Package lock file not found");
|
|
46
46
|
return () => "";
|
|
47
47
|
}
|
|
@@ -71,8 +71,8 @@ const getModulesInfo = async () => {
|
|
|
71
71
|
cli: getModuleVersion("@elliemae/pui-cli"),
|
|
72
72
|
dimsum: getModuleVersion("@elliemae/ds-system")
|
|
73
73
|
};
|
|
74
|
-
} catch
|
|
75
|
-
console.warn(
|
|
74
|
+
} catch {
|
|
75
|
+
console.warn("Package lock file not found");
|
|
76
76
|
return {};
|
|
77
77
|
}
|
|
78
78
|
};
|
|
@@ -176,7 +176,7 @@ const isPathExist = async (pathToCheck) => {
|
|
|
176
176
|
try {
|
|
177
177
|
await access(pathToCheck, constants.F_OK);
|
|
178
178
|
return true;
|
|
179
|
-
} catch
|
|
179
|
+
} catch {
|
|
180
180
|
return false;
|
|
181
181
|
}
|
|
182
182
|
};
|
package/dist/esm/index.cjs
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
const { babelConfig } = require('./babel.config.cjs');
|
|
2
|
+
const {
|
|
3
|
+
eslintFlatBaseConfig,
|
|
4
|
+
eslintFlatBaseConfigStrict,
|
|
5
|
+
} = require('./lint-config/eslint/flat/non-react-export.mjs');
|
|
6
|
+
const {
|
|
7
|
+
eslintFlatConfig,
|
|
8
|
+
eslintFlatConfigStrict,
|
|
9
|
+
} = require('./lint-config/eslint/flat/react-export.mjs');
|
|
2
10
|
const {
|
|
3
11
|
esConfig: eslintBaseConfig,
|
|
4
12
|
} = require('./lint-config/eslint/non-react.cjs');
|
|
@@ -13,6 +21,10 @@ const { jestNodeConfig } = require('./testing/jest.node.config.cjs');
|
|
|
13
21
|
|
|
14
22
|
module.exports = {
|
|
15
23
|
babelConfig,
|
|
24
|
+
eslintFlatBaseConfig,
|
|
25
|
+
eslintFlatBaseConfigStrict,
|
|
26
|
+
eslintFlatConfig,
|
|
27
|
+
eslintFlatConfigStrict,
|
|
16
28
|
eslintBaseConfig,
|
|
17
29
|
eslintConfig,
|
|
18
30
|
stylelintConfig,
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { babelConfig } from "./babel.config.cjs";
|
|
2
|
+
import {
|
|
3
|
+
eslintFlatBaseConfig,
|
|
4
|
+
eslintFlatBaseConfigStrict
|
|
5
|
+
} from "./lint-config/eslint/flat/non-react-export.mjs";
|
|
6
|
+
import {
|
|
7
|
+
eslintFlatConfig,
|
|
8
|
+
eslintFlatConfigStrict
|
|
9
|
+
} from "./lint-config/eslint/flat/react-export.mjs";
|
|
2
10
|
import { esConfig } from "./lint-config/eslint/non-react.cjs";
|
|
3
11
|
import { esReactConfig } from "./lint-config/eslint/react.cjs";
|
|
4
12
|
import { stylelintConfig } from "./lint-config/stylelint.config.cjs";
|
|
@@ -14,6 +22,10 @@ export {
|
|
|
14
22
|
commitlintConfig,
|
|
15
23
|
esConfig as eslintBaseConfig,
|
|
16
24
|
esReactConfig as eslintConfig,
|
|
25
|
+
eslintFlatBaseConfig,
|
|
26
|
+
eslintFlatBaseConfigStrict,
|
|
27
|
+
eslintFlatConfig,
|
|
28
|
+
eslintFlatConfigStrict,
|
|
17
29
|
jestConfig,
|
|
18
30
|
jestNodeConfig,
|
|
19
31
|
lintStagedConfig,
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
4
|
+
import eslintComments from 'eslint-plugin-eslint-comments';
|
|
5
|
+
import importX from 'eslint-plugin-import-x';
|
|
6
|
+
import jest from 'eslint-plugin-jest';
|
|
7
|
+
import testingLibrary from 'eslint-plugin-testing-library';
|
|
8
|
+
import wdio from 'eslint-plugin-wdio';
|
|
9
|
+
import globals from 'globals';
|
|
10
|
+
import tseslint from 'typescript-eslint';
|
|
11
|
+
import {
|
|
12
|
+
jestRecommendedRules,
|
|
13
|
+
sharedCoreRules,
|
|
14
|
+
storybookFiles,
|
|
15
|
+
testFiles,
|
|
16
|
+
testJsxFiles,
|
|
17
|
+
testingLibraryDomRules,
|
|
18
|
+
testingLibraryReactRules,
|
|
19
|
+
wdioGlobals,
|
|
20
|
+
wdioRecommendedRules,
|
|
21
|
+
wdioSpecFiles,
|
|
22
|
+
} from './presets.mjs';
|
|
23
|
+
import {
|
|
24
|
+
ignorePatterns,
|
|
25
|
+
jsRules,
|
|
26
|
+
typescriptRules,
|
|
27
|
+
typescriptStrictRules,
|
|
28
|
+
typescriptTestRelaxedRules,
|
|
29
|
+
} from './rules.mjs';
|
|
30
|
+
|
|
31
|
+
const tsconfigRootDir = process.cwd();
|
|
32
|
+
|
|
33
|
+
const typescriptParserOptions = {
|
|
34
|
+
projectService: true,
|
|
35
|
+
tsconfigRootDir,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Cached flat config arrays (only two variants: default + strict). */
|
|
39
|
+
const configCache = new Map();
|
|
40
|
+
|
|
41
|
+
/** @param {Record<string, unknown>} tsRules - `typescriptRules` or `typescriptStrictRules` */
|
|
42
|
+
export function createBaseFlatConfigs(tsRules) {
|
|
43
|
+
if (configCache.has(tsRules)) {
|
|
44
|
+
return configCache.get(tsRules);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const config = defineConfig(
|
|
48
|
+
{ ignores: ignorePatterns },
|
|
49
|
+
eslint.configs.recommended,
|
|
50
|
+
eslintConfigPrettier,
|
|
51
|
+
{
|
|
52
|
+
plugins: {
|
|
53
|
+
'eslint-comments': eslintComments,
|
|
54
|
+
'import-x': importX,
|
|
55
|
+
},
|
|
56
|
+
languageOptions: {
|
|
57
|
+
ecmaVersion: 'latest',
|
|
58
|
+
sourceType: 'module',
|
|
59
|
+
parserOptions: {
|
|
60
|
+
ecmaFeatures: { jsx: true },
|
|
61
|
+
},
|
|
62
|
+
globals: {
|
|
63
|
+
...globals.browser,
|
|
64
|
+
...globals.node,
|
|
65
|
+
...globals.es2021,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
settings: {
|
|
69
|
+
'import-x/resolver': {
|
|
70
|
+
node: { extensions: ['.js', '.jsx', '.ts', '.tsx'] },
|
|
71
|
+
typescript: { alwaysTryTypes: true },
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
rules: sharedCoreRules,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
files: ['**/*.{js,jsx,mjs,cjs}'],
|
|
78
|
+
rules: jsRules,
|
|
79
|
+
},
|
|
80
|
+
...tseslint.configs.recommendedTypeChecked.map((config) => ({
|
|
81
|
+
...config,
|
|
82
|
+
files: ['**/*.{ts,tsx}'],
|
|
83
|
+
})),
|
|
84
|
+
{
|
|
85
|
+
files: ['**/*.{ts,tsx}'],
|
|
86
|
+
rules: tsRules,
|
|
87
|
+
languageOptions: {
|
|
88
|
+
parserOptions: typescriptParserOptions,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
files: testFiles,
|
|
93
|
+
plugins: {
|
|
94
|
+
jest,
|
|
95
|
+
'testing-library': testingLibrary,
|
|
96
|
+
},
|
|
97
|
+
languageOptions: {
|
|
98
|
+
globals: globals.jest,
|
|
99
|
+
},
|
|
100
|
+
settings: {
|
|
101
|
+
jest: { version: 'detect' },
|
|
102
|
+
},
|
|
103
|
+
rules: {
|
|
104
|
+
...jestRecommendedRules,
|
|
105
|
+
...testingLibraryDomRules,
|
|
106
|
+
'testing-library/no-node-access': 'off',
|
|
107
|
+
...typescriptTestRelaxedRules,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
files: testJsxFiles,
|
|
112
|
+
rules: {
|
|
113
|
+
...testingLibraryReactRules,
|
|
114
|
+
'testing-library/no-node-access': 'off',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
files: wdioSpecFiles,
|
|
119
|
+
plugins: { wdio, jest },
|
|
120
|
+
languageOptions: { globals: wdioGlobals },
|
|
121
|
+
rules: {
|
|
122
|
+
...wdioRecommendedRules,
|
|
123
|
+
'jest/valid-expect': 'off',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
files: ['**/eslint.config.{mjs,cjs,js}'],
|
|
128
|
+
rules: { 'import-x/no-unresolved': 'off' },
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
files: ['**/scripts/**', '**/ci_cd/**'],
|
|
132
|
+
rules: {
|
|
133
|
+
'no-console': 'off',
|
|
134
|
+
'max-lines': 'off',
|
|
135
|
+
complexity: 'off',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
files: storybookFiles,
|
|
140
|
+
rules: { 'import-x/no-extraneous-dependencies': 'off' },
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
files: ['**/lint-config/**'],
|
|
144
|
+
rules: {
|
|
145
|
+
'max-lines': 'off',
|
|
146
|
+
'import-x/no-named-as-default-member': 'off',
|
|
147
|
+
'import-x/default': 'off',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
files: ['**/*.d.ts'],
|
|
152
|
+
rules: {
|
|
153
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
154
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
configCache.set(tsRules, config);
|
|
160
|
+
return config;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Default flat base — `no-unsafe-*` as warn in application TypeScript. */
|
|
164
|
+
export const baseFlatConfigs = createBaseFlatConfigs(typescriptRules);
|
|
165
|
+
|
|
166
|
+
/** Strict flat base — `no-unsafe-*` as error in application TypeScript. */
|
|
167
|
+
export const baseFlatConfigsStrict = createBaseFlatConfigs(typescriptStrictRules);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { eslintFlatConfig, eslintFlatConfigStrict } from './react-export.mjs';
|
|
2
|
+
export {
|
|
3
|
+
eslintFlatBaseConfig,
|
|
4
|
+
eslintFlatBaseConfigStrict,
|
|
5
|
+
} from './non-react-export.mjs';
|
|
6
|
+
export { reactFlatConfigs, reactFlatConfigsStrict } from './react.mjs';
|
|
7
|
+
export {
|
|
8
|
+
nonReactFlatConfigs,
|
|
9
|
+
nonReactFlatConfigsStrict,
|
|
10
|
+
} from './non-react.mjs';
|
|
11
|
+
export {
|
|
12
|
+
baseFlatConfigs,
|
|
13
|
+
baseFlatConfigsStrict,
|
|
14
|
+
createBaseFlatConfigs,
|
|
15
|
+
} from './common.mjs';
|
|
16
|
+
export {
|
|
17
|
+
storybookFiles,
|
|
18
|
+
testFiles,
|
|
19
|
+
testJsxFiles,
|
|
20
|
+
} from './presets.mjs';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
nonReactFlatConfigs,
|
|
3
|
+
nonReactFlatConfigsStrict,
|
|
4
|
+
} from './non-react.mjs';
|
|
5
|
+
|
|
6
|
+
/** Flat ESLint config for non-React TypeScript libraries and services. */
|
|
7
|
+
export const eslintFlatBaseConfig = nonReactFlatConfigs;
|
|
8
|
+
|
|
9
|
+
/** Strict flat ESLint config for non-React TypeScript (`no-unsafe-*` as error). */
|
|
10
|
+
export const eslintFlatBaseConfigStrict = nonReactFlatConfigsStrict;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preset rule bundles and file globs computed once at module load (not per config factory call).
|
|
3
|
+
*/
|
|
4
|
+
import eslintComments from 'eslint-plugin-eslint-comments';
|
|
5
|
+
import importX from 'eslint-plugin-import-x';
|
|
6
|
+
import jest from 'eslint-plugin-jest';
|
|
7
|
+
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
8
|
+
import react from 'eslint-plugin-react';
|
|
9
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
10
|
+
import reduxSaga from 'eslint-plugin-redux-saga';
|
|
11
|
+
import storybook from 'eslint-plugin-storybook';
|
|
12
|
+
import testingLibrary from 'eslint-plugin-testing-library';
|
|
13
|
+
import wdio from 'eslint-plugin-wdio';
|
|
14
|
+
|
|
15
|
+
export const testFiles = [
|
|
16
|
+
'**/*.{test,spec}.{js,jsx,ts,tsx}',
|
|
17
|
+
'**/__tests__/**',
|
|
18
|
+
'**/lib/testing/**',
|
|
19
|
+
'**/mocks/**',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export const testJsxFiles = ['**/*.{test,spec}.{jsx,tsx}'];
|
|
23
|
+
|
|
24
|
+
export const wdioSpecFiles = [
|
|
25
|
+
'**/*.func.spec.js',
|
|
26
|
+
'**/*.visual.spec.js',
|
|
27
|
+
'**/*e2e*.{js,ts}',
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export const storybookFiles = [
|
|
31
|
+
'**/*.stories.{js,jsx,ts,tsx}',
|
|
32
|
+
'**/.storybook/**',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
36
|
+
export const sharedCoreRules = {
|
|
37
|
+
...eslintComments.configs.recommended.rules,
|
|
38
|
+
...importX.configs.recommended.rules,
|
|
39
|
+
'import-x/named': 'off',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
43
|
+
export const jestRecommendedRules = jest.configs.recommended.rules;
|
|
44
|
+
|
|
45
|
+
const testingLibraryDom =
|
|
46
|
+
testingLibrary.configs['flat/dom'] ?? testingLibrary.configs.dom;
|
|
47
|
+
const testingLibraryReact =
|
|
48
|
+
testingLibrary.configs['flat/react'] ?? testingLibrary.configs.react;
|
|
49
|
+
|
|
50
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
51
|
+
export const testingLibraryDomRules = testingLibraryDom?.rules ?? {};
|
|
52
|
+
|
|
53
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
54
|
+
export const testingLibraryReactRules = testingLibraryReact?.rules ?? {};
|
|
55
|
+
|
|
56
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
57
|
+
export const reactPresetRules = {
|
|
58
|
+
...react.configs.recommended.rules,
|
|
59
|
+
...reactHooks.configs.recommended.rules,
|
|
60
|
+
...jsxA11y.flatConfigs.recommended.rules,
|
|
61
|
+
...reduxSaga.configs.recommended.rules,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** @type {import('eslint').Linter.RulesRecord} */
|
|
65
|
+
export const wdioRecommendedRules = wdio.configs.recommended.rules ?? {};
|
|
66
|
+
|
|
67
|
+
/** @type {Record<string, boolean>} */
|
|
68
|
+
export const wdioGlobals = wdio.configs.recommended.globals ?? {};
|
|
69
|
+
|
|
70
|
+
const storybookFlat =
|
|
71
|
+
storybook.configs['flat/recommended'] ??
|
|
72
|
+
storybook.configs.recommended ??
|
|
73
|
+
[];
|
|
74
|
+
|
|
75
|
+
/** Normalized once — Storybook flat config may be array or single object. */
|
|
76
|
+
export const storybookFlatConfigs = Array.isArray(storybookFlat)
|
|
77
|
+
? storybookFlat
|
|
78
|
+
: [storybookFlat];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { reactFlatConfigs, reactFlatConfigsStrict } from './react.mjs';
|
|
2
|
+
|
|
3
|
+
/** Flat ESLint config for React + TypeScript PUI apps. */
|
|
4
|
+
export const eslintFlatConfig = reactFlatConfigs;
|
|
5
|
+
|
|
6
|
+
/** Strict flat ESLint config for React + TypeScript (errors on `no-unsafe-*` and `exhaustive-deps`). */
|
|
7
|
+
export const eslintFlatConfigStrict = reactFlatConfigsStrict;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import jsxA11y from 'eslint-plugin-jsx-a11y';
|
|
3
|
+
import react from 'eslint-plugin-react';
|
|
4
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
5
|
+
import reduxSaga from 'eslint-plugin-redux-saga';
|
|
6
|
+
import { baseFlatConfigs, baseFlatConfigsStrict } from './common.mjs';
|
|
7
|
+
import {
|
|
8
|
+
reactPresetRules,
|
|
9
|
+
storybookFiles,
|
|
10
|
+
storybookFlatConfigs,
|
|
11
|
+
} from './presets.mjs';
|
|
12
|
+
import { reactRules, reactStrictRules } from './rules.mjs';
|
|
13
|
+
|
|
14
|
+
const reactPluginBlock = {
|
|
15
|
+
plugins: {
|
|
16
|
+
react,
|
|
17
|
+
'react-hooks': reactHooks,
|
|
18
|
+
'jsx-a11y': jsxA11y,
|
|
19
|
+
'redux-saga': reduxSaga,
|
|
20
|
+
},
|
|
21
|
+
settings: {
|
|
22
|
+
react: { version: 'detect' },
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {import('eslint').Linter.Config[]} baseConfigs
|
|
28
|
+
* @param {typeof reactRules} puiReactRules
|
|
29
|
+
*/
|
|
30
|
+
function createReactFlatConfigs(baseConfigs, puiReactRules) {
|
|
31
|
+
return defineConfig(
|
|
32
|
+
...baseConfigs,
|
|
33
|
+
{
|
|
34
|
+
...reactPluginBlock,
|
|
35
|
+
rules: {
|
|
36
|
+
...reactPresetRules,
|
|
37
|
+
...puiReactRules,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
...storybookFlatConfigs,
|
|
41
|
+
{
|
|
42
|
+
files: storybookFiles,
|
|
43
|
+
rules: {
|
|
44
|
+
'react/jsx-props-no-spreading': 'off',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Default React flat config — migration-friendly type-safety warnings. */
|
|
51
|
+
export const reactFlatConfigs = createReactFlatConfigs(
|
|
52
|
+
baseFlatConfigs,
|
|
53
|
+
reactRules,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
/** Strict React flat config — `no-unsafe-*` and `exhaustive-deps` as error. */
|
|
57
|
+
export const reactFlatConfigsStrict = createReactFlatConfigs(
|
|
58
|
+
baseFlatConfigsStrict,
|
|
59
|
+
reactStrictRules,
|
|
60
|
+
);
|