-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add recommended Next.js rules (#114)
- Loading branch information
1 parent
8649133
commit 825d6ba
Showing
3 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import type { Rules } from "../types"; | ||
|
||
import { interopDefault } from "../utils/interop-default"; | ||
import { warningAsErrors } from "../utils/warnings-as-errors"; | ||
|
||
export const nextjsRules = async () => { | ||
const nextjsPlugin = await interopDefault(import("@next/eslint-plugin-next")); | ||
|
||
return { | ||
...nextjsPlugin.configs["core-web-vitals"].rules, | ||
} satisfies Rules; | ||
return warningAsErrors( | ||
nextjsPlugin.configs.recommended.rules, | ||
) satisfies Rules; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { warningAsErrors } from "./warnings-as-errors"; | ||
|
||
describe("warningAsErrors", () => { | ||
it("should return empty object when no rules", () => { | ||
const ruleEntries = warningAsErrors(); | ||
|
||
expect(ruleEntries).toMatchInlineSnapshot(`{}`); | ||
}); | ||
|
||
it("should return empty object when empty rules", () => { | ||
const ruleEntries = warningAsErrors({}); | ||
|
||
expect(ruleEntries).toMatchInlineSnapshot(`{}`); | ||
}); | ||
|
||
it("should change warnings to errors", () => { | ||
const ruleEntries = warningAsErrors({ | ||
"react/forbid-prop-types": "warn", | ||
"react/jsx-uses-react": "error", | ||
"react/react-in-jsx-scope": "warn", | ||
}); | ||
|
||
expect(ruleEntries).toMatchInlineSnapshot(` | ||
{ | ||
"react/forbid-prop-types": "error", | ||
"react/jsx-uses-react": "error", | ||
"react/react-in-jsx-scope": "error", | ||
} | ||
`); | ||
}); | ||
}); |