Skip to content

Commit 3c5daa0

Browse files
committedJun 22, 2023
fix: removed extra "}" from react version, fixed plugin loading check, now the dev-dep and dep checking is correct
Signed-off-by: prisis <d.bannert@anolilab.de>
1 parent d81fa23 commit 3c5daa0

File tree

10 files changed

+29
-49
lines changed

10 files changed

+29
-49
lines changed
 

‎.prettierignore

-24
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
# Logs
66
logs
7-
*.log
87
npm-debug.log*
98
yarn-debug.log*
109
yarn-error.log*
@@ -26,9 +25,6 @@ lib-cov
2625
coverage
2726
*.lcov
2827

29-
# nyc test coverage
30-
.nyc_output
31-
3228
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
3329
.grunt
3430

@@ -45,12 +41,6 @@ build/Release
4541
node_modules/
4642
jspm_packages/
4743

48-
# TypeScript v1 declaration files
49-
typings/
50-
51-
# TypeScript cache
52-
*.tsbuildinfo
53-
5444
# Optional npm cache directory
5545
.npm
5646

@@ -69,18 +59,12 @@ typings/
6959
# Optional REPL history
7060
.node_repl_history
7161

72-
# Output of 'npm pack'
73-
*.tgz
74-
7562
# Yarn Integrity file
7663
.yarn-integrity
7764

7865
# dotenv environment variables file
79-
.env
8066
.env.test
8167

82-
# parcel-bundler cache (https://parceljs.org/)
83-
.cache
8468

8569
# Next.js build output
8670
.next
@@ -89,12 +73,6 @@ typings/
8973
.nuxt
9074
dist
9175

92-
# Gatsby files
93-
.cache/
94-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
95-
# https://nextjs.org/blog/next-9-1#public-directory-support
96-
# public
97-
9876
# vuepress build output
9977
.vuepress/dist
10078

@@ -128,8 +106,6 @@ CHANGELOG.*
128106

129107
# Package manager files
130108
pnpm-lock.yaml
131-
yarn.lock
132-
package-lock.json
133109
shrinkwrap.json
134110

135111
# Build outputs

‎.prettierrc.cjs ‎.prettierrc.js

File renamed without changes.

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
"postinstall": "is-ci || husky install",
6161
"lint:eslint": "cross-env NO_LOGS=true eslint -c ./.eslintrc.cjs --ext .js,.cjs,.mjs,.ts,.tsx ./packages --cache --cache-strategy content .",
6262
"lint:eslint:fix": "pnpm run lint:eslint --fix",
63-
"lint:prettier": "prettier --config=.prettierrc.cjs --write '**/*.{js,jsx,cjs,tsx,ts,less,md,json}'",
63+
"lint:prettier:root": "prettier --config=.prettierrc.js --check '*.{json,yml,yaml,js,ts}'",
64+
"lint:prettier:root:fix": "prettier --config=.prettierrc.js --write '*.{json,yml,yaml,js,ts}'",
6465
"lint:staged": "lint-staged --verbose",
6566
"lint:styles": "stylelint",
6667
"lint:text": "textlint ./.github/ ./packages/** ./README.md ./UPGRADE.md --parallel --experimental --cache --dry-run",

‎packages/eslint-config/src/config.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import {
2-
hasAnyDep, hasDependency, hasDevDependency, pkg,
3-
} from "@anolilab/package-json-utils";
1+
import { hasDependency, hasDevDependency, pkg } from "@anolilab/package-json-utils";
42

53
import type { PackageRules } from "./types";
64

@@ -153,18 +151,21 @@ pluginConfig.forEach((plugin) => {
153151
const { dependencies, configName } = plugin;
154152

155153
if (anolilabEslintConfig?.["plugin"]?.[configName] !== false) {
156-
if (
157-
hasAnyDep(dependencies, {
158-
peerDeps: false,
159-
strict: true,
160-
})
161-
) {
154+
const foundDependencies = [];
155+
156+
dependencies.forEach((dependency) => {
157+
if (hasDependency(dependency) || hasDevDependency(dependency)) {
158+
foundDependencies.push(dependency);
159+
}
160+
});
161+
162+
if (foundDependencies.length === dependencies.length) {
162163
loadedPlugins.push(configName);
163164
} else {
164165
possiblePlugins[configName] = {};
165166

166167
dependencies.forEach((dependency) => {
167-
(possiblePlugins[configName] as { [key: string]: boolean })[dependency] = hasDependency(dependency) ?? hasDevDependency(dependency);
168+
(possiblePlugins[configName] as { [key: string]: boolean })[dependency] = hasDependency(dependency) || hasDevDependency(dependency);
168169
});
169170
}
170171
}

‎packages/eslint-config/src/config/plugins/html.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (
2020
"@html-eslint/no-extra-spacing-attrs": "off",
2121
"@html-eslint/element-newline": "off",
2222
"@html-eslint/quotes": "off",
23-
}
23+
};
2424
}
2525

2626
const config: Linter.Config = {
@@ -44,7 +44,7 @@ const config: Linter.Config = {
4444
"@html-eslint/indent": hasPrettier ? "off" : ["error", (styleRules["indent"] as any[])[1]],
4545

4646
...prettierRules,
47-
}
47+
},
4848
},
4949
],
5050
};

‎packages/eslint-config/src/config/plugins/react.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const config: Linter.Config = {
9797
// The default value is "detect". Automatic detection works by loading the entire React library
9898
// into the linter's process, which is inefficient. It is recommended to specify the version
9999
// explicity.
100-
version: reactDependency[0] ? `${reactDependency[0]}.${reactDependency[1] ?? "0"}}` : "detect",
100+
version: reactDependency[0] ? `${reactDependency[0]}.${reactDependency[1] ?? "0"}` : "detect",
101101
},
102102
propWrapperFunctions: [
103103
"forbidExtraProps", // https://www.npmjs.com/package/airbnb-prop-types

‎packages/eslint-config/src/postinstall.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const writeEslintRc = () => {
3737
if (tsConfig.compilerOptions?.target) {
3838
ecmaVersion = tsConfig.compilerOptions.target;
3939

40-
ecmaVersion = ecmaVersion.toLowerCase() === "es2022" || ecmaVersion.toLowerCase() === "esnext" ? "latest" : ecmaVersion.toLowerCase().replace("es", "");
40+
ecmaVersion =
41+
ecmaVersion.toLowerCase() === "es2022" || ecmaVersion.toLowerCase() === "esnext" ? "latest" : ecmaVersion.toLowerCase().replace("es", "");
4142

4243
if (ecmaVersion !== "latest" && ecmaVersion !== "2022" && ecmaVersion !== "2021" && ecmaVersion !== "2021" && ecmaVersion !== "6") {
4344
pluginExtends = `, "plugin:es/restrict-to-es${ecmaVersion}"`;

‎packages/eslint-config/src/utils/create-config.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { Linter } from "eslint";
22

3-
const createConfig = (type: "all" | "javascript" | "js_and_ts" | "jsx_and_tsx" | "typescript", config: Omit<Linter.Config, "files|overrides">): Linter.Config => {
3+
const createConfig = (
4+
type: "all" | "javascript" | "js_and_ts" | "jsx_and_tsx" | "typescript",
5+
config: Omit<Linter.Config, "files|overrides">,
6+
): Linter.Config => {
47
let files = ["*.js", "*.mjs", "*.cjs"];
58

69
// eslint-disable-next-line default-case

‎packages/eslint-config/src/utils/loggers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const noop = () => undefined;
22

33
const consolePrefix = (prefix: string) =>
44
// eslint-disable-next-line implicit-arrow-linebreak
5-
(process.env["NO_LOGS"] ? noop : (message: string) => console.log(`${prefix}${message}`));
5+
process.env["NO_LOGS"] ? noop : (message: string) => console.log(`${prefix}${message}`);
66

77
export const consolePlugin = consolePrefix(" eslint-plugin-");
88
export const consoleLog = consolePrefix("");

‎tsup.config.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const getPackageSources = (packageContent: NormalizedPackageJson): string[] => {
1515
}
1616

1717
throw new TypeError("Please define a source or sources key in the package.json.");
18-
}
18+
};
1919

2020
export const createConfig = (config?: Object & Options) =>
2121
baseDefineConfig((options: Options) => {
@@ -29,13 +29,7 @@ export const createConfig = (config?: Object & Options) =>
2929
entry: sources,
3030
treeshake: true,
3131
// react external https://github.com/vercel/turborepo/issues/360#issuecomment-1013885148
32-
external: [
33-
...new Set([
34-
...peerDependenciesKeys,
35-
...Object.keys(packageJsonContent.optionalDependencies || {}),
36-
...(config?.external || []),
37-
]),
38-
],
32+
external: [...new Set([...peerDependenciesKeys, ...Object.keys(packageJsonContent.optionalDependencies || {}), ...(config?.external || [])])],
3933
format: ["esm", "cjs"],
4034
silent: !options.watch,
4135
minify: process.env["NODE_ENV"] === "production",
@@ -54,6 +48,10 @@ export const createConfig = (config?: Object & Options) =>
5448
if (process.env["NODE_ENV"] !== "production" && peerDependenciesKeys.includes("react")) {
5549
options.tsconfig = options.tsconfig?.replace("tsconfig.json", "tsconfig.dev.json");
5650
}
51+
52+
options.logOverride = {
53+
"tsconfig.json": "silent",
54+
}
5755
},
5856
...config,
5957
};

0 commit comments

Comments
 (0)
Please sign in to comment.