@zayne-labs/eslint-config 0.2.5 → 0.2.7
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 +15 -15
- package/dist/index.d.ts +330 -166
- package/dist/index.js +43 -16
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url';
|
|
2
|
-
import { isObject } from '@zayne-labs/toolkit/type-helpers';
|
|
3
2
|
import { isPackageExists } from 'local-pkg';
|
|
4
3
|
import globals from 'globals';
|
|
5
4
|
import { fixupPluginRules } from '@eslint/compat';
|
|
6
5
|
import { FlatConfigComposer } from 'eslint-flat-config-utils';
|
|
7
6
|
|
|
8
7
|
// src/utils.ts
|
|
8
|
+
var isObject = (value) => {
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
+
};
|
|
9
11
|
var combine = async (...configs) => {
|
|
10
12
|
const resolved = await Promise.all(configs);
|
|
11
13
|
return resolved.flat();
|
|
@@ -971,9 +973,10 @@ var defaultPluginRenameMap = {
|
|
|
971
973
|
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
972
974
|
"@eslint-react/naming-convention": "react-naming-convention",
|
|
973
975
|
"@eslint-react/web-api": "react-web-api",
|
|
974
|
-
//
|
|
976
|
+
// @eslint-react has to be below the rest to avoid rename issues
|
|
975
977
|
// eslint-disable-next-line perfectionist/sort-objects
|
|
976
978
|
"@eslint-react": "react",
|
|
979
|
+
"@next/next": "nextjs-next",
|
|
977
980
|
"@stylistic": "stylistic",
|
|
978
981
|
"@tanstack/query": "tanstack-query",
|
|
979
982
|
"@typescript-eslint": "ts-eslint",
|
|
@@ -983,24 +986,26 @@ var defaultPluginRenameMap = {
|
|
|
983
986
|
var ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
984
987
|
var RemixPackages = ["@remix-run/node", "@remix-run/react", "@remix-run/serve", "@remix-run/dev"];
|
|
985
988
|
var NextJsPackages = ["next"];
|
|
989
|
+
var isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
|
|
990
|
+
var isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
|
|
991
|
+
var isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
|
|
986
992
|
var react = async (options = {}) => {
|
|
987
|
-
const { files = [GLOB_SRC], overrides, typescript: typescript2 = true } = options;
|
|
993
|
+
const { files = [GLOB_SRC], nextjs = isUsingNext, overrides, typescript: typescript2 = true } = options;
|
|
988
994
|
await ensurePackages([
|
|
989
995
|
"@eslint-react/eslint-plugin",
|
|
990
996
|
"eslint-plugin-react-hooks",
|
|
991
997
|
"eslint-plugin-react-refresh",
|
|
998
|
+
...nextjs ? ["@next/eslint-plugin-next"] : [],
|
|
992
999
|
"typescript-eslint"
|
|
993
1000
|
]);
|
|
994
|
-
const [eslintPluginReact, eslintReactHooks, eslintPluginReactRefresh] = await Promise.all([
|
|
1001
|
+
const [eslintPluginReact, eslintReactHooks, eslintPluginReactRefresh, eslintPluginNextjs] = await Promise.all([
|
|
995
1002
|
interopDefault(import('@eslint-react/eslint-plugin')),
|
|
996
1003
|
interopDefault(import('eslint-plugin-react-hooks')),
|
|
997
|
-
interopDefault(import('eslint-plugin-react-refresh'))
|
|
1004
|
+
interopDefault(import('eslint-plugin-react-refresh')),
|
|
1005
|
+
...nextjs ? [interopDefault(import('@next/eslint-plugin-next'))] : []
|
|
998
1006
|
]);
|
|
999
|
-
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
|
|
1000
|
-
const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
|
|
1001
|
-
const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
|
|
1002
1007
|
const recommendedReactConfig = eslintPluginReact.configs[typescript2 ? "recommended-type-checked" : "recommended"];
|
|
1003
|
-
|
|
1008
|
+
const config = [
|
|
1004
1009
|
{
|
|
1005
1010
|
name: "zayne/react/setup",
|
|
1006
1011
|
plugins: {
|
|
@@ -1071,16 +1076,38 @@ var react = async (options = {}) => {
|
|
|
1071
1076
|
}
|
|
1072
1077
|
}
|
|
1073
1078
|
];
|
|
1079
|
+
if (nextjs && eslintPluginNextjs) {
|
|
1080
|
+
config.push({
|
|
1081
|
+
files,
|
|
1082
|
+
name: "zayne/react/next",
|
|
1083
|
+
plugins: {
|
|
1084
|
+
"nextjs-next": fixupPluginRules(eslintPluginNextjs)
|
|
1085
|
+
},
|
|
1086
|
+
rules: renameRules(
|
|
1087
|
+
/* eslint-disable ts-eslint/no-unsafe-argument, ts-eslint/no-unsafe-member-access */
|
|
1088
|
+
{
|
|
1089
|
+
// @ts-expect-error - eslint-plugin-nextjs is not typed
|
|
1090
|
+
...eslintPluginNextjs.configs?.recommended?.rules,
|
|
1091
|
+
// @ts-expect-error - eslint-plugin-nextjs is not typed
|
|
1092
|
+
...eslintPluginNextjs.configs?.["core-web-vitals"]?.rules
|
|
1093
|
+
},
|
|
1094
|
+
defaultPluginRenameMap
|
|
1095
|
+
)
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
return config;
|
|
1074
1099
|
};
|
|
1075
1100
|
|
|
1076
1101
|
// src/configs/tanstack.ts
|
|
1077
1102
|
var tanstack = async (options = {}) => {
|
|
1078
1103
|
const { query = true } = options;
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1104
|
+
const config = [];
|
|
1105
|
+
await ensurePackages([...query ? ["@tanstack/eslint-plugin-query"] : []]);
|
|
1106
|
+
const [eslintPluginTanstackQuery] = await Promise.all(
|
|
1107
|
+
query ? [interopDefault(import('@tanstack/eslint-plugin-query'))] : []
|
|
1108
|
+
);
|
|
1109
|
+
if (query && eslintPluginTanstackQuery) {
|
|
1110
|
+
config.push({
|
|
1084
1111
|
name: "zayne/tanstack/query-recommended",
|
|
1085
1112
|
plugins: {
|
|
1086
1113
|
"tanstack-query": eslintPluginTanstackQuery
|
|
@@ -1091,7 +1118,7 @@ var tanstack = async (options = {}) => {
|
|
|
1091
1118
|
)
|
|
1092
1119
|
});
|
|
1093
1120
|
}
|
|
1094
|
-
return
|
|
1121
|
+
return config;
|
|
1095
1122
|
};
|
|
1096
1123
|
|
|
1097
1124
|
// src/configs/sort.ts
|
|
@@ -1468,6 +1495,6 @@ var zayne = (options = {}, userConfigs = []) => {
|
|
|
1468
1495
|
return composer;
|
|
1469
1496
|
};
|
|
1470
1497
|
|
|
1471
|
-
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, combine, zayne as default, ensurePackages, gitIgnores, ignores, imports, interopDefault, isPackageInScope, javascript, jsdoc, jsonc, node, perfectionist, react, renamePluginInConfigs, renamePlugins, renameRules, sortPackageJson, sortTsconfig, stylistic, tailwindcss, tanstack, typescript, unicorn, zayne };
|
|
1498
|
+
export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, combine, zayne as default, ensurePackages, gitIgnores, ignores, imports, interopDefault, isObject, isPackageInScope, javascript, jsdoc, jsonc, node, perfectionist, react, renamePluginInConfigs, renamePlugins, renameRules, sortPackageJson, sortTsconfig, stylistic, tailwindcss, tanstack, typescript, unicorn, zayne };
|
|
1472
1499
|
//# sourceMappingURL=index.js.map
|
|
1473
1500
|
//# sourceMappingURL=index.js.map
|