Skip to content

Commit

Permalink
feat: ✨ add eslint-plugin-jsdoc rules
Browse files Browse the repository at this point in the history
🏁 Closes: #88
  • Loading branch information
jimmy-guzman committed Dec 6, 2024
1 parent 02437a1 commit 1b88e97
Show file tree
Hide file tree
Showing 11 changed files with 1,159 additions and 342 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"eslint-plugin-import-x": "^4.5.0",
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-jest-dom": "^5.5.0",
"eslint-plugin-jsdoc": "^50.6.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-n": "^17.14.0",
"eslint-plugin-perfectionist": "^4.2.0",
Expand All @@ -88,23 +89,23 @@
"@semantic-release/git": "10.0.1",
"@semantic-release/npm": "12.0.1",
"@semantic-release/release-notes-generator": "14.0.1",
"@tanstack/react-query": "5.62.2",
"@tanstack/react-query": "5.62.3",
"@testing-library/dom": "10.4.0",
"@testing-library/react": "16.1.0",
"@total-typescript/ts-reset": "0.6.1",
"@types/node": "22.10.1",
"@types/react": "18.3.12",
"@vitest/coverage-v8": "2.1.8",
"astro": "4.16.16",
"astro": "5.0.3",
"clean-pkg-json": "1.2.0",
"commitlint": "19.6.0",
"eslint": "9.16.0",
"eslint-typegen": "0.3.2",
"gitzy": "5.7.1",
"is-ci": "3.0.1",
"jiti": "2.4.1",
"lefthook": "1.8.5",
"next": "15.0.3",
"lefthook": "1.9.0",
"next": "15.0.4",
"pkgroll": "2.5.1",
"prettier": "3.4.2",
"react": "18.3.1",
Expand All @@ -118,7 +119,7 @@
"peerDependencies": {
"eslint": "^9.10.0"
},
"packageManager": "pnpm@9.14.4",
"packageManager": "pnpm@9.15.0",
"engines": {
"node": ">= 20"
},
Expand Down
584 changes: 262 additions & 322 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/configs/jsdoc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import jsdocPlugin from "eslint-plugin-jsdoc";

import { jsdocRules } from "../rules/jsdoc";

export const jsdocConfig = () => {
return [
{
...jsdocPlugin.configs["flat/recommended-typescript-error"],
name: "jimmy.codes/jsdoc",
rules: jsdocRules(),
},
];
};
27 changes: 14 additions & 13 deletions src/factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("eslintConfig", () => {
"ignores",
"javascript",
"regexp",
"jsdoc",
])("should create configuration w/ %s", async (input) => {
await expect(eslintConfig({ autoDetect: false })).resolves.toStrictEqual(
expect.arrayContaining([
Expand Down Expand Up @@ -63,7 +64,7 @@ describe("eslintConfig", () => {
it("should create configuration w/ jest", async () => {
const configs = await eslintConfig({ autoDetect: false, jest: true });

expect(configs.at(7)?.name).toBe("jimmy.codes/jest");
expect(configs.at(8)?.name).toBe("jimmy.codes/jest");
});

it("should create configuration w/ jest (deprecated)", async () => {
Expand All @@ -80,7 +81,7 @@ describe("eslintConfig", () => {
it("should create configuration w/ vitest", async () => {
const configs = await eslintConfig({ autoDetect: false, vitest: true });

expect(configs.at(7)?.name).toBe("jimmy.codes/vitest");
expect(configs.at(8)?.name).toBe("jimmy.codes/vitest");
});

it("should create configuration w/ vitest (deprecated)", async () => {
Expand All @@ -102,9 +103,9 @@ describe("eslintConfig", () => {
testingLibrary: true,
});

expect(configs.at(7)?.name).toBe("jimmy.codes/react");
expect(configs.at(8)?.name).toBe("jimmy.codes/jest");
expect(configs.at(9)?.name).toBe("jimmy.codes/testing-library");
expect(configs.at(8)?.name).toBe("jimmy.codes/react");
expect(configs.at(9)?.name).toBe("jimmy.codes/jest");
expect(configs.at(10)?.name).toBe("jimmy.codes/testing-library");
});

it("should create configuration w/ jest & react & testing library (deprecated)", async () => {
Expand All @@ -131,9 +132,9 @@ describe("eslintConfig", () => {
vitest: true,
});

expect(configs.at(7)?.name).toBe("jimmy.codes/react");
expect(configs.at(8)?.name).toBe("jimmy.codes/vitest");
expect(configs.at(9)?.name).toBe("jimmy.codes/testing-library");
expect(configs.at(8)?.name).toBe("jimmy.codes/react");
expect(configs.at(9)?.name).toBe("jimmy.codes/vitest");
expect(configs.at(10)?.name).toBe("jimmy.codes/testing-library");
});

it("should create configuration w/ vitest & react & testing library (deprecated)", async () => {
Expand Down Expand Up @@ -186,7 +187,7 @@ describe("eslintConfig", () => {
tanstackQuery: true,
});

expect(configs.at(7)?.name).toBe("jimmy.codes/react/query");
expect(configs.at(8)?.name).toBe("jimmy.codes/react/query");
});

it("should create configuration w/ storybook", async () => {
Expand All @@ -195,7 +196,7 @@ describe("eslintConfig", () => {
storybook: true,
});

expect(configs.at(7)?.name).toBe("jimmy.codes/storybook/setup");
expect(configs.at(8)?.name).toBe("jimmy.codes/storybook/setup");
});

it("should create configuration w/ nextjs", async () => {
Expand All @@ -204,7 +205,7 @@ describe("eslintConfig", () => {
nextjs: true,
});

expect(configs.at(7)?.name).toBe("jimmy.codes/nextjs");
expect(configs.at(8)?.name).toBe("jimmy.codes/nextjs");
});

describe("autoDetect", () => {
Expand Down Expand Up @@ -356,7 +357,7 @@ describe("eslintConfig", () => {
autoDetect: true,
});

expect(configs.at(7)?.name).toBe("jimmy.codes/storybook/setup");
expect(configs.at(8)?.name).toBe("jimmy.codes/storybook/setup");
});

it("should include nextjs when auto detection is enabled", async () => {
Expand All @@ -368,7 +369,7 @@ describe("eslintConfig", () => {
autoDetect: true,
});

expect(configs.at(7)?.name).toBe("jimmy.codes/nextjs");
expect(configs.at(8)?.name).toBe("jimmy.codes/nextjs");
});
});
});
2 changes: 2 additions & 0 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { eslintCommentsConfig } from "./configs/eslint-comments";
import { ignoresConfig } from "./configs/ignores";
import { importsConfig } from "./configs/imports";
import { javascriptConfig } from "./configs/javascript";
import { jsdocConfig } from "./configs/jsdoc";
import { nextjsConfig } from "./configs/nextjs";
import { nodeConfig } from "./configs/node";
import { perfectionistConfig } from "./configs/perfectionist";
Expand Down Expand Up @@ -93,6 +94,7 @@ export const eslintConfig = async (
unicornConfig(),
eslintCommentsConfig(),
regexpConfig(),
jsdocConfig(),
importsConfig({ typescript: isTypescriptEnabled }),
isTypescriptEnabled ? typescriptConfig(typescriptOptions) : [],
isReactEnabled ? await reactConfig() : [],
Expand Down
Loading

0 comments on commit 1b88e97

Please sign in to comment.