From 380d95c777d218eda31f9bc8d3e0952526752db3 Mon Sep 17 00:00:00 2001 From: Jesko Plitt Date: Wed, 29 Jan 2025 15:45:43 +0100 Subject: [PATCH] Fix turborepo and use react/jsx-curly-brace-presence --- .changeset/flat-pillows-kneel.md | 5 +++ .changeset/young-apes-whisper.md | 5 +++ package-lock.json | 34 +++++----------- packages/eslint/README.md | 22 +++++++++++ packages/eslint/base.js | 9 ----- packages/eslint/eslint.js | 12 ------ packages/eslint/next.js | 64 ++++++++++++++++--------------- packages/eslint/package.json | 1 - packages/eslint/react-internal.js | 50 +++++++++++++----------- 9 files changed, 102 insertions(+), 100 deletions(-) create mode 100644 .changeset/flat-pillows-kneel.md create mode 100644 .changeset/young-apes-whisper.md delete mode 100644 packages/eslint/eslint.js diff --git a/.changeset/flat-pillows-kneel.md b/.changeset/flat-pillows-kneel.md new file mode 100644 index 0000000..314d2fa --- /dev/null +++ b/.changeset/flat-pillows-kneel.md @@ -0,0 +1,5 @@ +--- +"@becklyn/eslint": patch +--- + +Fix turborepo integration diff --git a/.changeset/young-apes-whisper.md b/.changeset/young-apes-whisper.md new file mode 100644 index 0000000..513c3ab --- /dev/null +++ b/.changeset/young-apes-whisper.md @@ -0,0 +1,5 @@ +--- +"@becklyn/eslint": patch +--- + +Use react/jsx-curly-brace-presence diff --git a/package-lock.json b/package-lock.json index b82a9e9..9ae4117 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1907,15 +1907,6 @@ "node": ">=0.10.0" } }, - "node_modules/dotenv": { - "version": "16.0.3", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", - "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - } - }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -2252,19 +2243,6 @@ "semver": "bin/semver.js" } }, - "node_modules/eslint-plugin-turbo": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-turbo/-/eslint-plugin-turbo-2.3.4.tgz", - "integrity": "sha512-9ncoUJkQGkC28NmlQiS17oB9mrE8XaSulRZiB5pv9vmRbYjOfUwyGhY3EIcoBRdww81igxOzXmAmvNNd6GFBPg==", - "license": "MIT", - "dependencies": { - "dotenv": "16.0.3" - }, - "peerDependencies": { - "eslint": ">6.6.0", - "turbo": ">2.0.0" - } - }, "node_modules/eslint-scope": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", @@ -4677,6 +4655,7 @@ "version": "2.3.4", "resolved": "https://registry.npmjs.org/turbo/-/turbo-2.3.4.tgz", "integrity": "sha512-1kiLO5C0Okh5ay1DbHsxkPsw9Sjsbjzm6cF85CpWjR0BIyBFNDbKqtUyqGADRS1dbbZoQanJZVj4MS5kk8J42Q==", + "dev": true, "license": "MIT", "bin": { "turbo": "bin/turbo" @@ -4697,6 +4676,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4710,6 +4690,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4723,6 +4704,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4736,6 +4718,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4749,6 +4732,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -4762,6 +4746,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5048,7 +5033,7 @@ }, "packages/eslint": { "name": "@becklyn/eslint", - "version": "0.1.1", + "version": "1.0.2", "license": "MIT", "dependencies": { "@eslint/js": "^9.19.0", @@ -5059,7 +5044,6 @@ "eslint-plugin-only-warn": "^1.1.0", "eslint-plugin-react": "^7.37.4", "eslint-plugin-react-hooks": "^5.1.0", - "eslint-plugin-turbo": "^2.3.4", "globals": "^15.14.0", "typescript": "^5.7.3", "typescript-eslint": "^8.22.0" @@ -5079,7 +5063,7 @@ }, "packages/tsconfig": { "name": "@becklyn/tsconfig", - "version": "0.1.1", + "version": "1.0.0", "license": "MIT" } } diff --git a/packages/eslint/README.md b/packages/eslint/README.md index 131d95c..cfecb8f 100644 --- a/packages/eslint/README.md +++ b/packages/eslint/README.md @@ -37,3 +37,25 @@ import { config } from "@becklyn/eslint/base"; /** @type {import("eslint").Linter.Config} */ export default config; ``` + + +## Turborepo + +When using turborepo you might want to check for undeclared env variables. + +Install `eslint-plugin-turbo`: `npm install -D eslint-plugin-turbo` + +```js +import { config } from "@becklyn/eslint/base"; +import turboPlugin from "eslint-plugin-turbo"; + +/** @type {import("eslint").Linter.Config} */ +export default [...nextJsConfig, { + plugins: { + turbo: turboPlugin, + }, + rules: { + "turbo/no-undeclared-env-vars": "warn", + }, +}]; +``` diff --git a/packages/eslint/base.js b/packages/eslint/base.js index ebe8172..38c3008 100644 --- a/packages/eslint/base.js +++ b/packages/eslint/base.js @@ -1,6 +1,5 @@ import js from "@eslint/js"; import eslintConfigPrettier from "eslint-config-prettier"; -import turboPlugin from "eslint-plugin-turbo"; import tseslint from "typescript-eslint"; import importAlias from "@limegrass/eslint-plugin-import-alias"; @@ -26,14 +25,6 @@ export const config = [ ], }, }, - { - plugins: { - turbo: turboPlugin, - }, - rules: { - "turbo/no-undeclared-env-vars": "warn", - }, - }, { ignores: ["dist/**"], }, diff --git a/packages/eslint/eslint.js b/packages/eslint/eslint.js deleted file mode 100644 index 22d424e..0000000 --- a/packages/eslint/eslint.js +++ /dev/null @@ -1,12 +0,0 @@ -/** @type {import("eslint").Linter.Config} */ -module.exports = { - plugins: ["react"], - extends: ["next"], - rules: { - "react/jsx-curly-brace-presence": [ - 2, - { props: "never", children: "never", propElementValues: "ignore" }, - ], - }, - ignorePatterns: ["node_modules/", "dist/"], -}; diff --git a/packages/eslint/next.js b/packages/eslint/next.js index 1997af7..696b8b9 100644 --- a/packages/eslint/next.js +++ b/packages/eslint/next.js @@ -13,37 +13,41 @@ import { config as baseConfig } from "./base.js"; * @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, - }, + ...baseConfig, + js.configs.recommended, + eslintConfigPrettier, + ...tseslint.configs.recommended, + { + ...pluginReact.configs.flat.recommended, + languageOptions: { + ...pluginReact.configs.flat.recommended.languageOptions, + globals: { + ...globals.serviceworker, + }, + }, }, - }, - { - plugins: { - "@next/next": pluginNext, + { + plugins: { + "@next/next": pluginNext, + }, + rules: { + ...pluginNext.configs.recommended.rules, + ...pluginNext.configs["core-web-vitals"].rules, + }, }, - rules: { - ...pluginNext.configs.recommended.rules, - ...pluginNext.configs["core-web-vitals"].rules, + { + 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", + "react/jsx-curly-brace-presence": [ + "error", + { props: "never", children: "never", propElementValues: "ignore" }, + ], + }, }, - }, - { - 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", - }, - }, ]; diff --git a/packages/eslint/package.json b/packages/eslint/package.json index 3d816ab..ff58d8a 100644 --- a/packages/eslint/package.json +++ b/packages/eslint/package.json @@ -27,7 +27,6 @@ "eslint-plugin-only-warn": "^1.1.0", "eslint-plugin-react": "^7.37.4", "eslint-plugin-react-hooks": "^5.1.0", - "eslint-plugin-turbo": "^2.3.4", "globals": "^15.14.0", "typescript": "^5.7.3", "typescript-eslint": "^8.22.0" diff --git a/packages/eslint/react-internal.js b/packages/eslint/react-internal.js index 0cc8b1d..b0b1216 100644 --- a/packages/eslint/react-internal.js +++ b/packages/eslint/react-internal.js @@ -11,29 +11,33 @@ import { config as baseConfig } from "./base.js"; * * @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, - }, + ...baseConfig, + js.configs.recommended, + eslintConfigPrettier, + ...tseslint.configs.recommended, + pluginReact.configs.flat.recommended, + { + languageOptions: { + ...pluginReact.configs.flat.recommended.languageOptions, + globals: { + ...globals.serviceworker, + ...globals.browser, + }, + }, }, - }, - { - plugins: { - "react-hooks": pluginReactHooks, + { + 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", + "react/jsx-curly-brace-presence": [ + "error", + { props: "never", children: "never", propElementValues: "ignore" }, + ], + }, }, - settings: { react: { version: "detect" } }, - rules: { - ...pluginReactHooks.configs.recommended.rules, - // React scope no longer necessary with new JSX transform. - "react/react-in-jsx-scope": "off", - }, - }, ];