Skip to content

Commit f166a11

Browse files
committed
feat: more work on the configs
Signed-off-by: prisis <[email protected]>
1 parent 85e6f05 commit f166a11

27 files changed

+25180
-16155
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,14 @@
6363
"lint": "pnpm run lint:prettier && pnpm run lint:eslint",
6464
"lint:eslint": "nx run-many --target=lint:eslint --all --parallel",
6565
"lint:eslint:fix": "nx run-many --target=lint:eslint:fix --all --parallel",
66-
"lint:fix": "pnpm run lint:prettier:fix && pnpm run lint:eslint:fix && pnpm run sort-package-json",
66+
"lint:fix": "pnpm run lint:prettier:fix && pnpm run lint:eslint:fix",
6767
"lint:prettier": "nx run-many --target=lint:prettier --all --parallel",
6868
"lint:prettier:fix": "nx run-many --target=lint:prettier:fix --all --parallel",
6969
"lint:secrets": "secretlint **/*",
7070
"lint:staged": "lint-staged --verbose --concurrent false --debug",
7171
"lint:styles": "stylelint",
7272
"lint:text": "textlint ./.github/ ./packages/** ./README.md ./UPGRADE.md --parallel --experimental --cache --dry-run",
7373
"lint:text:fix": "textlint ./.github/ ./packages/** ./README.md ./UPGRADE.md --parallel --experimental --fix",
74-
"sort-package-json": "sort-package-json ./packages/**/package.json ./package.json",
7574
"test:all": "nx run-many --target=test:coverage --projects=browserslist-config-anolilab,stylelint-config,eslint-config && pnpm test:stylelint",
7675
"test:browserslist-config-anolilab": "pnpm --filter \"browserslist-config-anolilab\" run test",
7776
"test:coverage:browserslist-config-anolilab": "pnpm --filter \"browserslist-config-anolilab\" run test:coverage",
@@ -111,7 +110,6 @@
111110
"rimraf": "^6.0.1",
112111
"secretlint": "9.0.0",
113112
"semantic-release": "^24.2.0",
114-
"sort-package-json": "^2.12.0",
115113
"stylelint": "^16.12.0",
116114
"taze": "^0.18.0",
117115
"textlint": "^14.4.2",

packages/eslint-config/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ Add this property to your package.json:
242242

243243
```json5
244244
{
245-
anolilab: {
245+
"anolilab": {
246246
"eslint-config": {
247247
// options
248-
},
249-
},
248+
}
249+
}
250250
}
251251
```
252252

packages/eslint-config/__tests__/old-config-loading.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { rm } from "node:fs/promises";
33
import { join } from "node:path";
44
import { promisify } from "node:util";
55

6-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
6+
import {
7+
afterEach,
8+
beforeEach,
9+
describe,
10+
expect,
11+
it,
12+
} from "vitest";
713

814
const ONE_SECOND_IN_MS = 1000;
915

@@ -25,6 +31,7 @@ describe("integration - old config", () => {
2531
"installs & works",
2632
async () => {
2733
expect.assertions(2);
34+
2835
await execAsync("pnpm --ignore-workspace i", { cwd: TEST_DIR });
2936

3037
const { stderr, stdout } = await execAsync("pnpm exec eslint -c ./.eslintrc.js . || true", {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { createConfig } from "./dist/index.mjs"
1+
import { createConfig } from "./dist";
22

33
export default createConfig({});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { createConfig } from "./dist/index.mjs";
2+
3+
export default createConfig(
4+
{
5+
ignores: ["eslint.config.js", "typegen.d.ts"],
6+
},
7+
{
8+
files: ["**/*.ts"],
9+
rules: {
10+
"no-secrets/no-secrets": "off",
11+
},
12+
},
13+
);

packages/eslint-config/package.json

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@
7676
"type": "module",
7777
"exports": {
7878
".": {
79-
"require": {
80-
"types": "./dist/index.d.cts",
81-
"default": "./dist/index.cjs"
82-
},
8379
"import": {
8480
"types": "./dist/index.d.tjs",
8581
"default": "./dist/index.mjs"
82+
},
83+
"require": {
84+
"types": "./dist/index.d.cts",
85+
"default": "./dist/index.cjs"
8686
}
8787
},
8888
"./package.json": "./package.json"
@@ -98,10 +98,10 @@
9898
}
9999
},
100100
"files": [
101-
"dist",
102-
"README.md",
103101
"CHANGELOG.md",
104-
"LICENSE.md"
102+
"LICENSE.md",
103+
"README.md",
104+
"dist"
105105
],
106106
"scripts": {
107107
"build": "packem build --development",
@@ -110,6 +110,8 @@
110110
"clean": "rimraf node_modules dist",
111111
"debug:rules": "pnpm exec eslint-config-inspector --config ./debug-eslint.config.mjs",
112112
"lint:attw": "attw --pack",
113+
"lint:eslint": "eslint .",
114+
"lint:eslint:fix": "eslint . --fix",
113115
"lint:prettier": "prettier --config=.prettierrc.cjs --check .",
114116
"lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
115117
"test": "vitest run",
@@ -129,10 +131,10 @@
129131
"@html-eslint/parser": "^0.32.0",
130132
"@stylistic/eslint-plugin": "^2.12.1",
131133
"@stylistic/eslint-plugin-ts": "^2.12.1",
132-
"@typescript-eslint/eslint-plugin": "^8.19.0",
133-
"@typescript-eslint/parser": "^8.19.0",
134-
"@visulima/package": "^3.4.0",
135-
"@visulima/tsconfig": "^1.1.4",
134+
"@typescript-eslint/eslint-plugin": "^8.19.1",
135+
"@typescript-eslint/parser": "^8.19.1",
136+
"@visulima/package": "^3.4.2",
137+
"@visulima/tsconfig": "^1.1.6",
136138
"@vitest/eslint-plugin": "^1.1.24",
137139
"confusing-browser-globals": "^1.0.11",
138140
"eslint-config-flat-gitignore": "^0.3.0",
@@ -168,37 +170,37 @@
168170
"parse-gitignore": "^2.0.0",
169171
"semver": "^7.6.3",
170172
"toml-eslint-parser": "^0.10.0",
171-
"typescript-eslint": "^8.19.0",
173+
"typescript-eslint": "^8.19.1",
172174
"yaml-eslint-parser": "^1.2.3"
173175
},
174176
"devDependencies": {
175177
"@anolilab/prettier-config": "^5.0.14",
176178
"@anolilab/semantic-release-preset": "9.0.3",
177-
"@eslint-react/eslint-plugin": "^1.23.1",
178-
"@eslint/config-inspector": "^0.7.0",
179+
"@eslint-react/eslint-plugin": "^1.23.2",
180+
"@eslint/config-inspector": "^0.7.1",
179181
"@stylistic/eslint-plugin-migrate": "^2.12.1",
180-
"@tanstack/eslint-plugin-query": "^5.0.0",
182+
"@tanstack/eslint-plugin-query": "^5.62.16",
181183
"@tanstack/eslint-plugin-router": "^1.92.7",
182184
"@testing-library/dom": "^10.4.0",
183185
"@total-typescript/ts-reset": "^0.6.1",
184186
"@types/confusing-browser-globals": "^1.0.3",
185187
"@types/eslint": "^9.6.1",
186188
"@types/eslint-plugin-tailwindcss": "^3.17.0",
187189
"@types/semver": "^7.5.8",
188-
"@unocss/eslint-plugin": "^0.65.3",
189-
"@visulima/packem": "^1.10.2",
190+
"@unocss/eslint-plugin": "^0.65.4",
191+
"@visulima/packem": "^1.10.7",
190192
"astro-eslint-parser": "^1.1.0",
191193
"esbuild": "^0.24.2",
192194
"eslint": "^9.17.0",
193195
"eslint-plugin-astro": "^1.3.1",
194-
"eslint-plugin-format": "^0.1.3",
196+
"eslint-plugin-format": "^1.0.1",
195197
"eslint-plugin-jsx-a11y": "^6.10.2",
196198
"eslint-plugin-react-hooks": "^5.1.0",
197199
"eslint-plugin-react-refresh": "^0.4.16",
198200
"eslint-plugin-storybook": "^0.11.2",
199201
"eslint-plugin-tailwindcss": "^3.17.5",
200202
"eslint-plugin-testing-library": "^7.1.1",
201-
"eslint-plugin-tsdoc": "^0.2.17",
203+
"eslint-plugin-tsdoc": "^0.4.0",
202204
"eslint-plugin-validate-jsx-nesting": "^0.1.1",
203205
"eslint-plugin-vitest": "^0.5.4",
204206
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
@@ -210,7 +212,7 @@
210212
"semantic-release": "^24.2.1",
211213
"tsx": "^4.19.2",
212214
"type-fest": "^4.31.0",
213-
"typescript": "^5.7.2",
215+
"typescript": "^5.7.3",
214216
"vitest": "^2.1.8"
215217
},
216218
"peerDependencies": {

packages/eslint-config/packem.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { defineConfig } from "@visulima/packem/config";
22
import transformer from "@visulima/packem/transformer/esbuild";
33

4-
// eslint-disable-next-line import/no-unused-modules
54
export default defineConfig({
65
declaration: false,
76
rollup: {
@@ -13,10 +12,10 @@ export default defineConfig({
1312
writeToPackageJson: true,
1413
},
1514
},
15+
transformer,
1616
validation: {
1717
packageJson: {
1818
exports: false,
1919
},
2020
},
21-
transformer,
2221
});

packages/eslint-config/src/config/best-practices.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ export default createConfig<OptionsFiles>("all", async (config, oFiles) => {
451451
// https://eslint.org/docs/rules/no-void
452452
"no-void": "error",
453453

454+
// eslint-disable-next-line sonarjs/todo-tag
454455
// disallow usage of configurable warning terms in comments: e.g. todo
455456
"no-warning-comments": [
456457
"off",

packages/eslint-config/src/config/plugins/formatters.ts

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import type {
2-
OptionsFormatters,
3-
StylisticConfig,
4-
TypedFlatConfigItem,
5-
} from "../../types";
1+
import type { OptionsFormatters, StylisticConfig, TypedFlatConfigItem } from "../../types";
62
import { getFilesGlobs } from "../../utils/create-config";
73
import interopDefault from "../../utils/interop-default";
84
import parserPlain from "../../utils/parser-plain";
@@ -228,34 +224,37 @@ const formatters = async (options: OptionsFormatters, stylistic: StylisticConfig
228224
}
229225

230226
if (options.astro) {
231-
configs.push({
232-
files: getFilesGlobs("astro"),
233-
languageOptions: {
234-
parser: parserPlain,
235-
},
236-
name: "anolilab/formatter/astro",
237-
rules: {
238-
"format/prettier": [
239-
"error",
240-
mergePrettierOptions(prettierOptions, {
241-
parser: "astro",
242-
plugins: ["prettier-plugin-astro"],
243-
}),
244-
],
227+
configs.push(
228+
{
229+
files: getFilesGlobs("astro"),
230+
languageOptions: {
231+
parser: parserPlain,
232+
},
233+
name: "anolilab/formatter/astro",
234+
rules: {
235+
"format/prettier": [
236+
"error",
237+
mergePrettierOptions(prettierOptions, {
238+
parser: "astro",
239+
plugins: ["prettier-plugin-astro"],
240+
}),
241+
],
242+
},
245243
},
246-
}, {
247-
files: [...getFilesGlobs("astro"), ...getFilesGlobs("astro_ts")],
248-
name: "anolilab/formatter/astro/disables",
249-
rules: {
250-
"@stylistic/arrow-parens": "off",
251-
"@stylistic/block-spacing": "off",
252-
"@stylistic/comma-dangle": "off",
253-
"@stylistic/indent": "off",
254-
"@stylistic/no-multi-spaces": "off",
255-
"@stylistic/quotes": "off",
256-
"@stylistic/semi": "off",
244+
{
245+
files: [...getFilesGlobs("astro"), ...getFilesGlobs("astro_ts")],
246+
name: "anolilab/formatter/astro/disables",
247+
rules: {
248+
"@stylistic/arrow-parens": "off",
249+
"@stylistic/block-spacing": "off",
250+
"@stylistic/comma-dangle": "off",
251+
"@stylistic/indent": "off",
252+
"@stylistic/no-multi-spaces": "off",
253+
"@stylistic/quotes": "off",
254+
"@stylistic/semi": "off",
255+
},
257256
},
258-
});
257+
);
259258
}
260259

261260
if (options.graphql) {

packages/eslint-config/src/config/plugins/imports.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export default createConfig<OptionsCwd & OptionsFiles & OptionsOverrides & Optio
133133
"import/no-amd": "error",
134134

135135
// Reports if a module's default export is unnamed
136-
// eslint-disable-next-line no-secrets/no-secrets
136+
137137
// https://github.com/import-js/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
138138
"import/no-anonymous-default-export": [
139139
"off",
@@ -172,7 +172,7 @@ export default createConfig<OptionsCwd & OptionsFiles & OptionsOverrides & Optio
172172
"import/no-dynamic-require": "error",
173173

174174
// Reports the use of empty named import blocks.
175-
// eslint-disable-next-line no-secrets/no-secrets
175+
176176
// https://github.com/un-es/eslint-plugin-i/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/no-empty-named-blocks.md
177177
"import/no-empty-named-blocks": "error",
178178

@@ -286,6 +286,7 @@ export default createConfig<OptionsCwd & OptionsFiles & OptionsOverrides & Optio
286286
// https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md
287287
"import/no-self-import": "error",
288288

289+
// eslint-disable-next-line sonarjs/todo-tag
289290
// @TODO: Enable this rule when it's fixed https://github.com/import-js/eslint-plugin-import/issues/2678
290291
// Reports modules without any exports, or with unused exports
291292
// https://github.com/import-js/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md

packages/eslint-config/src/config/plugins/jsdoc.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
11
import { hasPackageJsonAnyDependency } from "@visulima/package";
22

3-
import type { OptionsFiles, OptionsPackageJson, OptionsStylistic } from "../../types";
3+
import type {
4+
OptionsFiles,
5+
OptionsPackageJson,
6+
OptionsSilentConsoleLogs,
7+
OptionsStylistic,
8+
} from "../../types";
49
import { createConfig, getFilesGlobs } from "../../utils/create-config";
510
import interopDefault from "../../utils/interop-default";
611

7-
export default createConfig<OptionsFiles & OptionsPackageJson & OptionsStylistic>("js", async (config, oFiles) => {
8-
const { files = oFiles, packageJson, stylistic = true } = config;
12+
export default createConfig<OptionsFiles & OptionsPackageJson & OptionsSilentConsoleLogs & OptionsStylistic>("js", async (config, oFiles) => {
13+
const {
14+
files = oFiles,
15+
packageJson,
16+
silent,
17+
stylistic = true,
18+
} = config;
919

1020
const jsdocPlugin = await interopDefault(import("eslint-plugin-jsdoc"));
1121

1222
const hasTypescript = hasPackageJsonAnyDependency(packageJson, ["typescript"]);
1323
const hasTsDocumentPlugin = hasPackageJsonAnyDependency(packageJson, ["eslint-plugin-tsdoc"]);
1424

15-
if (hasTsDocumentPlugin) {
25+
if (hasTsDocumentPlugin && !silent) {
26+
// eslint-disable-next-line no-console
1627
console.info("\nFound eslint-plugin-tsdoc as dependency, disabling the jsdoc rules for *.ts and *.tsx files.");
1728
}
1829

0 commit comments

Comments
 (0)