Skip to content

Commit

Permalink
feat: more work on the configs
Browse files Browse the repository at this point in the history
Signed-off-by: prisis <[email protected]>
  • Loading branch information
prisis committed Jan 9, 2025
1 parent 85e6f05 commit f166a11
Show file tree
Hide file tree
Showing 27 changed files with 25,180 additions and 16,155 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,14 @@
"lint": "pnpm run lint:prettier && pnpm run lint:eslint",
"lint:eslint": "nx run-many --target=lint:eslint --all --parallel",
"lint:eslint:fix": "nx run-many --target=lint:eslint:fix --all --parallel",
"lint:fix": "pnpm run lint:prettier:fix && pnpm run lint:eslint:fix && pnpm run sort-package-json",
"lint:fix": "pnpm run lint:prettier:fix && pnpm run lint:eslint:fix",
"lint:prettier": "nx run-many --target=lint:prettier --all --parallel",
"lint:prettier:fix": "nx run-many --target=lint:prettier:fix --all --parallel",
"lint:secrets": "secretlint **/*",
"lint:staged": "lint-staged --verbose --concurrent false --debug",
"lint:styles": "stylelint",
"lint:text": "textlint ./.github/ ./packages/** ./README.md ./UPGRADE.md --parallel --experimental --cache --dry-run",
"lint:text:fix": "textlint ./.github/ ./packages/** ./README.md ./UPGRADE.md --parallel --experimental --fix",
"sort-package-json": "sort-package-json ./packages/**/package.json ./package.json",
"test:all": "nx run-many --target=test:coverage --projects=browserslist-config-anolilab,stylelint-config,eslint-config && pnpm test:stylelint",
"test:browserslist-config-anolilab": "pnpm --filter \"browserslist-config-anolilab\" run test",
"test:coverage:browserslist-config-anolilab": "pnpm --filter \"browserslist-config-anolilab\" run test:coverage",
Expand Down Expand Up @@ -111,7 +110,6 @@
"rimraf": "^6.0.1",
"secretlint": "9.0.0",
"semantic-release": "^24.2.0",
"sort-package-json": "^2.12.0",
"stylelint": "^16.12.0",
"taze": "^0.18.0",
"textlint": "^14.4.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ Add this property to your package.json:

```json5
{
anolilab: {
"anolilab": {
"eslint-config": {
// options
},
},
}
}
}
```

Expand Down
9 changes: 8 additions & 1 deletion packages/eslint-config/__tests__/old-config-loading.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { rm } from "node:fs/promises";
import { join } from "node:path";
import { promisify } from "node:util";

import { afterEach, beforeEach, describe, expect, it } from "vitest";
import {
afterEach,
beforeEach,
describe,
expect,
it,
} from "vitest";

const ONE_SECOND_IN_MS = 1000;

Expand All @@ -25,6 +31,7 @@ describe("integration - old config", () => {
"installs & works",
async () => {
expect.assertions(2);

await execAsync("pnpm --ignore-workspace i", { cwd: TEST_DIR });

const { stderr, stdout } = await execAsync("pnpm exec eslint -c ./.eslintrc.js . || true", {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/debug-eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createConfig } from "./dist/index.mjs"
import { createConfig } from "./dist";

export default createConfig({});
13 changes: 13 additions & 0 deletions packages/eslint-config/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { createConfig } from "./dist/index.mjs";

export default createConfig(
{
ignores: ["eslint.config.js", "typegen.d.ts"],
},
{
files: ["**/*.ts"],
rules: {
"no-secrets/no-secrets": "off",
},
},
);
42 changes: 22 additions & 20 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
"type": "module",
"exports": {
".": {
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
},
"import": {
"types": "./dist/index.d.tjs",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
Expand All @@ -98,10 +98,10 @@
}
},
"files": [
"dist",
"README.md",
"CHANGELOG.md",
"LICENSE.md"
"LICENSE.md",
"README.md",
"dist"
],
"scripts": {
"build": "packem build --development",
Expand All @@ -110,6 +110,8 @@
"clean": "rimraf node_modules dist",
"debug:rules": "pnpm exec eslint-config-inspector --config ./debug-eslint.config.mjs",
"lint:attw": "attw --pack",
"lint:eslint": "eslint .",
"lint:eslint:fix": "eslint . --fix",
"lint:prettier": "prettier --config=.prettierrc.cjs --check .",
"lint:prettier:fix": "prettier --config=.prettierrc.cjs --write .",
"test": "vitest run",
Expand All @@ -129,10 +131,10 @@
"@html-eslint/parser": "^0.32.0",
"@stylistic/eslint-plugin": "^2.12.1",
"@stylistic/eslint-plugin-ts": "^2.12.1",
"@typescript-eslint/eslint-plugin": "^8.19.0",
"@typescript-eslint/parser": "^8.19.0",
"@visulima/package": "^3.4.0",
"@visulima/tsconfig": "^1.1.4",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.19.1",
"@visulima/package": "^3.4.2",
"@visulima/tsconfig": "^1.1.6",
"@vitest/eslint-plugin": "^1.1.24",
"confusing-browser-globals": "^1.0.11",
"eslint-config-flat-gitignore": "^0.3.0",
Expand Down Expand Up @@ -168,37 +170,37 @@
"parse-gitignore": "^2.0.0",
"semver": "^7.6.3",
"toml-eslint-parser": "^0.10.0",
"typescript-eslint": "^8.19.0",
"typescript-eslint": "^8.19.1",
"yaml-eslint-parser": "^1.2.3"
},
"devDependencies": {
"@anolilab/prettier-config": "^5.0.14",
"@anolilab/semantic-release-preset": "9.0.3",
"@eslint-react/eslint-plugin": "^1.23.1",
"@eslint/config-inspector": "^0.7.0",
"@eslint-react/eslint-plugin": "^1.23.2",
"@eslint/config-inspector": "^0.7.1",
"@stylistic/eslint-plugin-migrate": "^2.12.1",
"@tanstack/eslint-plugin-query": "^5.0.0",
"@tanstack/eslint-plugin-query": "^5.62.16",
"@tanstack/eslint-plugin-router": "^1.92.7",
"@testing-library/dom": "^10.4.0",
"@total-typescript/ts-reset": "^0.6.1",
"@types/confusing-browser-globals": "^1.0.3",
"@types/eslint": "^9.6.1",
"@types/eslint-plugin-tailwindcss": "^3.17.0",
"@types/semver": "^7.5.8",
"@unocss/eslint-plugin": "^0.65.3",
"@visulima/packem": "^1.10.2",
"@unocss/eslint-plugin": "^0.65.4",
"@visulima/packem": "^1.10.7",
"astro-eslint-parser": "^1.1.0",
"esbuild": "^0.24.2",
"eslint": "^9.17.0",
"eslint-plugin-astro": "^1.3.1",
"eslint-plugin-format": "^0.1.3",
"eslint-plugin-format": "^1.0.1",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.16",
"eslint-plugin-storybook": "^0.11.2",
"eslint-plugin-tailwindcss": "^3.17.5",
"eslint-plugin-testing-library": "^7.1.1",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-tsdoc": "^0.4.0",
"eslint-plugin-validate-jsx-nesting": "^0.1.1",
"eslint-plugin-vitest": "^0.5.4",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
Expand All @@ -210,7 +212,7 @@
"semantic-release": "^24.2.1",
"tsx": "^4.19.2",
"type-fest": "^4.31.0",
"typescript": "^5.7.2",
"typescript": "^5.7.3",
"vitest": "^2.1.8"
},
"peerDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-config/packem.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defineConfig } from "@visulima/packem/config";
import transformer from "@visulima/packem/transformer/esbuild";

// eslint-disable-next-line import/no-unused-modules
export default defineConfig({
declaration: false,
rollup: {
Expand All @@ -13,10 +12,10 @@ export default defineConfig({
writeToPackageJson: true,
},
},
transformer,
validation: {
packageJson: {
exports: false,
},
},
transformer,
});
1 change: 1 addition & 0 deletions packages/eslint-config/src/config/best-practices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ export default createConfig<OptionsFiles>("all", async (config, oFiles) => {
// https://eslint.org/docs/rules/no-void
"no-void": "error",

// eslint-disable-next-line sonarjs/todo-tag
// disallow usage of configurable warning terms in comments: e.g. todo
"no-warning-comments": [
"off",
Expand Down
61 changes: 30 additions & 31 deletions packages/eslint-config/src/config/plugins/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type {
OptionsFormatters,
StylisticConfig,
TypedFlatConfigItem,
} from "../../types";
import type { OptionsFormatters, StylisticConfig, TypedFlatConfigItem } from "../../types";
import { getFilesGlobs } from "../../utils/create-config";
import interopDefault from "../../utils/interop-default";
import parserPlain from "../../utils/parser-plain";
Expand Down Expand Up @@ -228,34 +224,37 @@ const formatters = async (options: OptionsFormatters, stylistic: StylisticConfig
}

if (options.astro) {
configs.push({
files: getFilesGlobs("astro"),
languageOptions: {
parser: parserPlain,
},
name: "anolilab/formatter/astro",
rules: {
"format/prettier": [
"error",
mergePrettierOptions(prettierOptions, {
parser: "astro",
plugins: ["prettier-plugin-astro"],
}),
],
configs.push(
{
files: getFilesGlobs("astro"),
languageOptions: {
parser: parserPlain,
},
name: "anolilab/formatter/astro",
rules: {
"format/prettier": [
"error",
mergePrettierOptions(prettierOptions, {
parser: "astro",
plugins: ["prettier-plugin-astro"],
}),
],
},
},
}, {
files: [...getFilesGlobs("astro"), ...getFilesGlobs("astro_ts")],
name: "anolilab/formatter/astro/disables",
rules: {
"@stylistic/arrow-parens": "off",
"@stylistic/block-spacing": "off",
"@stylistic/comma-dangle": "off",
"@stylistic/indent": "off",
"@stylistic/no-multi-spaces": "off",
"@stylistic/quotes": "off",
"@stylistic/semi": "off",
{
files: [...getFilesGlobs("astro"), ...getFilesGlobs("astro_ts")],
name: "anolilab/formatter/astro/disables",
rules: {
"@stylistic/arrow-parens": "off",
"@stylistic/block-spacing": "off",
"@stylistic/comma-dangle": "off",
"@stylistic/indent": "off",
"@stylistic/no-multi-spaces": "off",
"@stylistic/quotes": "off",
"@stylistic/semi": "off",
},
},
});
);
}

if (options.graphql) {
Expand Down
5 changes: 3 additions & 2 deletions packages/eslint-config/src/config/plugins/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default createConfig<OptionsCwd & OptionsFiles & OptionsOverrides & Optio
"import/no-amd": "error",

// Reports if a module's default export is unnamed
// eslint-disable-next-line no-secrets/no-secrets

// https://github.com/import-js/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
"import/no-anonymous-default-export": [
"off",
Expand Down Expand Up @@ -172,7 +172,7 @@ export default createConfig<OptionsCwd & OptionsFiles & OptionsOverrides & Optio
"import/no-dynamic-require": "error",

// Reports the use of empty named import blocks.
// eslint-disable-next-line no-secrets/no-secrets

// https://github.com/un-es/eslint-plugin-i/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/no-empty-named-blocks.md
"import/no-empty-named-blocks": "error",

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

// eslint-disable-next-line sonarjs/todo-tag
// @TODO: Enable this rule when it's fixed https://github.com/import-js/eslint-plugin-import/issues/2678
// Reports modules without any exports, or with unused exports
// https://github.com/import-js/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
Expand Down
19 changes: 15 additions & 4 deletions packages/eslint-config/src/config/plugins/jsdoc.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import { hasPackageJsonAnyDependency } from "@visulima/package";

import type { OptionsFiles, OptionsPackageJson, OptionsStylistic } from "../../types";
import type {
OptionsFiles,
OptionsPackageJson,
OptionsSilentConsoleLogs,
OptionsStylistic,
} from "../../types";
import { createConfig, getFilesGlobs } from "../../utils/create-config";
import interopDefault from "../../utils/interop-default";

export default createConfig<OptionsFiles & OptionsPackageJson & OptionsStylistic>("js", async (config, oFiles) => {
const { files = oFiles, packageJson, stylistic = true } = config;
export default createConfig<OptionsFiles & OptionsPackageJson & OptionsSilentConsoleLogs & OptionsStylistic>("js", async (config, oFiles) => {
const {
files = oFiles,
packageJson,
silent,
stylistic = true,
} = config;

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

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

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

Expand Down
Loading

0 comments on commit f166a11

Please sign in to comment.