-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update
basic
example to ESLint v9 and Flat Configurations. (#…
…9501) ### Description This PR converts our `basic` example to ESLint v9 with Flat Configurations. I may have a few gray hairs now, but I'm very excited for the community to have this. ### Testing Instructions Use `npx create-turbo@canary -e https://github.com/vercel/turborepo/tree/shew-409f3/examples/basic basic-eslint-9` to try it out. - Pull it down, make sure you see diagnostics where you'd expect in your editor. Including for `eslint-config-turbo`, most importantly! - I know the diff is big, but there may be vestigials from my experimenting lying around. Please use a finely toothed comb! (I've looked myself but the more eyes, the better.) --------- Co-authored-by: vincenthsh <111712068+vincenthsh@users.noreply.github.com>
- Loading branch information
1 parent
cbb85b3
commit b00eea2
Showing
21 changed files
with
2,435 additions
and
4,319 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
import { nextJsConfig } from "@repo/eslint-config/next-js"; | ||
|
||
/** @type {import("eslint").Linter.Config} */ | ||
export default nextJsConfig; |
File renamed without changes.
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
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
import { nextJsConfig } from "@repo/eslint-config/next-js"; | ||
|
||
/** @type {import("eslint").Linter.Config} */ | ||
export default nextJsConfig; |
File renamed without changes.
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
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
import js from "@eslint/js"; | ||
import eslintConfigPrettier from "eslint-config-prettier"; | ||
import turboPlugin from "eslint-plugin-turbo"; | ||
import tseslint from "typescript-eslint"; | ||
import onlyWarn from "eslint-plugin-only-warn"; | ||
|
||
/** | ||
* A shared ESLint configuration for the repository. | ||
* | ||
* @type {import("eslint").Linter.Config} | ||
* */ | ||
export const config = [ | ||
js.configs.recommended, | ||
eslintConfigPrettier, | ||
...tseslint.configs.recommended, | ||
{ | ||
plugins: { | ||
turbo: turboPlugin, | ||
}, | ||
rules: { | ||
"turbo/no-undeclared-env-vars": "warn", | ||
}, | ||
}, | ||
{ | ||
plugins: { | ||
onlyWarn, | ||
}, | ||
}, | ||
{ | ||
ignores: ["dist/**"], | ||
}, | ||
]; |
This file was deleted.
Oops, something went wrong.
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,35 +1,49 @@ | ||
const { resolve } = require("node:path"); | ||
import js from "@eslint/js"; | ||
import eslintConfigPrettier from "eslint-config-prettier"; | ||
import tseslint from "typescript-eslint"; | ||
import pluginReactHooks from "eslint-plugin-react-hooks"; | ||
import pluginReact from "eslint-plugin-react"; | ||
import globals from "globals"; | ||
import pluginNext from "@next/eslint-plugin-next"; | ||
import { config as baseConfig } from "./base.js"; | ||
|
||
const project = resolve(process.cwd(), "tsconfig.json"); | ||
|
||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
extends: [ | ||
"eslint:recommended", | ||
"prettier", | ||
require.resolve("@vercel/style-guide/eslint/next"), | ||
"turbo", | ||
], | ||
globals: { | ||
React: true, | ||
JSX: true, | ||
/** | ||
* A custom ESLint configuration for libraries that use React. | ||
* | ||
* @type {import("eslint").Linter.Config} | ||
* */ | ||
export const nextJsConfig = [ | ||
...baseConfig, | ||
js.configs.recommended, | ||
eslintConfigPrettier, | ||
...tseslint.configs.recommended, | ||
{ | ||
...pluginReact.configs.flat.recommended, | ||
languageOptions: { | ||
...pluginReact.configs.flat.recommended.languageOptions, | ||
globals: { | ||
...globals.serviceworker, | ||
}, | ||
}, | ||
}, | ||
env: { | ||
node: true, | ||
browser: true, | ||
{ | ||
plugins: { | ||
"@next/next": pluginNext, | ||
}, | ||
rules: { | ||
...pluginNext.configs.recommended.rules, | ||
...pluginNext.configs["core-web-vitals"].rules, | ||
}, | ||
}, | ||
plugins: ["only-warn"], | ||
settings: { | ||
"import/resolver": { | ||
typescript: { | ||
project, | ||
}, | ||
{ | ||
plugins: { | ||
"react-hooks": pluginReactHooks, | ||
}, | ||
settings: { react: { version: "detect" } }, | ||
rules: { | ||
...pluginReactHooks.configs.recommended.rules, | ||
// React scope no longer necessary with new JSX transform. | ||
"react/react-in-jsx-scope": "off", | ||
}, | ||
}, | ||
ignorePatterns: [ | ||
// Ignore dotfiles | ||
".*.js", | ||
"node_modules/", | ||
], | ||
overrides: [{ files: ["*.js?(x)", "*.ts?(x)"] }], | ||
}; | ||
]; |
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,19 +1,25 @@ | ||
{ | ||
"name": "@repo/eslint-config", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"private": true, | ||
"files": [ | ||
"library.js", | ||
"next.js", | ||
"react-internal.js" | ||
], | ||
"exports": { | ||
"./base": "./base.js", | ||
"./next-js": "./next.js", | ||
"./react-internal": "./react-internal.js" | ||
}, | ||
"devDependencies": { | ||
"@vercel/style-guide": "^5.2.0", | ||
"eslint-config-turbo": "^2.0.0", | ||
"@next/eslint-plugin-next": "^15", | ||
"@typescript-eslint/eslint-plugin": "^8.15.0", | ||
"@typescript-eslint/parser": "^8.15.0", | ||
"eslint": "^9.15.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-only-warn": "^1.1.0", | ||
"@typescript-eslint/parser": "^7.1.0", | ||
"@typescript-eslint/eslint-plugin": "^7.1.0", | ||
"typescript": "5.5.4" | ||
"eslint-plugin-react": "^7.37.2", | ||
"eslint-plugin-react-hooks": "^5.0.0", | ||
"eslint-plugin-turbo": "^2.3.0", | ||
"globals": "^15.12.0", | ||
"typescript": "^5.3.3", | ||
"typescript-eslint": "^8.15.0" | ||
} | ||
} |
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,38 +1,39 @@ | ||
const { resolve } = require("node:path"); | ||
import js from "@eslint/js"; | ||
import eslintConfigPrettier from "eslint-config-prettier"; | ||
import tseslint from "typescript-eslint"; | ||
import pluginReactHooks from "eslint-plugin-react-hooks"; | ||
import pluginReact from "eslint-plugin-react"; | ||
import globals from "globals"; | ||
import { config as baseConfig } from "./base.js"; | ||
|
||
const project = resolve(process.cwd(), "tsconfig.json"); | ||
|
||
/* | ||
* This is a custom ESLint configuration for use with | ||
* internal (bundled by their consumer) libraries | ||
* that utilize React. | ||
*/ | ||
|
||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
extends: ["eslint:recommended", "prettier", "turbo"], | ||
plugins: ["only-warn"], | ||
globals: { | ||
React: true, | ||
}, | ||
env: { | ||
browser: true, | ||
}, | ||
settings: { | ||
"import/resolver": { | ||
typescript: { | ||
project, | ||
/** | ||
* A custom ESLint configuration for libraries that use React. | ||
* | ||
* @type {import("eslint").Linter.Config} */ | ||
export const config = [ | ||
...baseConfig, | ||
js.configs.recommended, | ||
eslintConfigPrettier, | ||
...tseslint.configs.recommended, | ||
pluginReact.configs.flat.recommended, | ||
{ | ||
languageOptions: { | ||
...pluginReact.configs.flat.recommended.languageOptions, | ||
globals: { | ||
...globals.serviceworker, | ||
...globals.browser, | ||
}, | ||
}, | ||
}, | ||
ignorePatterns: [ | ||
// Ignore dotfiles | ||
".*.js", | ||
"node_modules/", | ||
"dist/", | ||
], | ||
overrides: [ | ||
// Force ESLint to detect .tsx files | ||
{ files: ["*.js?(x)", "*.ts?(x)"] }, | ||
], | ||
}; | ||
{ | ||
plugins: { | ||
"react-hooks": pluginReactHooks, | ||
}, | ||
settings: { react: { version: "detect" } }, | ||
rules: { | ||
...pluginReactHooks.configs.recommended.rules, | ||
// React scope no longer necessary with new JSX transform. | ||
"react/react-in-jsx-scope": "off", | ||
}, | ||
}, | ||
]; |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
import { config } from "@repo/eslint-config/react-internal"; | ||
|
||
/** @type {import("eslint").Linter.Config} */ | ||
export default config; |
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
Oops, something went wrong.