Skip to content

Commit

Permalink
feat: next.js plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
omermecitoglu committed Dec 3, 2024
1 parent 42234dd commit 37be6bf
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
5 changes: 5 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ declare module "eslint-plugin-import" {
const value: unknown;
export default value;
}

declare module "@next/eslint-plugin-next" {
const value: any;
export default value;
}
41 changes: 41 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"typescript-eslint": "^8.15.0"
},
"devDependencies": {
"@next/eslint-plugin-next": "^15.0.3",
"@types/eslint__js": "^8.42.3",
"@types/eslint-plugin-jsx-a11y": "^6.9.0",
"eslint": "^9.15.0",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base from "./base.js";
import importPlugin from "./import.js";
import { loadJsxAccessibilityConfig } from "./jsx-a11y.js";
import { loadNextConfig } from "./next.js";
import { loadReactConfig } from "./react.js";
import stylistic from "./stylistic.js";
import typescript from "./typescript.js";
Expand All @@ -13,6 +14,7 @@ export default [
...typescript,
...(await loadReactConfig()),
...(await loadJsxAccessibilityConfig()),
...(await loadNextConfig()),
...importPlugin,
...unusedImports,
] as Linter.Config[];
20 changes: 20 additions & 0 deletions src/next.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { Linter } from "eslint";

export async function loadNextConfig() {
try {
const { default: nextPlugin } = await import("@next/eslint-plugin-next");
return [
{
plugins: {
"@next/next": nextPlugin,
},
rules: {
...nextPlugin.configs.recommended.rules,
...nextPlugin.configs["core-web-vitals"].rules,
},
},
] as Linter.Config[];
} catch {
return [];
}
}

0 comments on commit 37be6bf

Please sign in to comment.