Skip to content

Commit

Permalink
Fix turborepo and use react/jsx-curly-brace-presence
Browse files Browse the repository at this point in the history
  • Loading branch information
jesko-plitt committed Jan 29, 2025
1 parent 3933266 commit 380d95c
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 100 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-pillows-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@becklyn/eslint": patch
---

Fix turborepo integration
5 changes: 5 additions & 0 deletions .changeset/young-apes-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@becklyn/eslint": patch
---

Use react/jsx-curly-brace-presence
34 changes: 9 additions & 25 deletions package-lock.json

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

22 changes: 22 additions & 0 deletions packages/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}];
```
9 changes: 0 additions & 9 deletions packages/eslint/base.js
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -26,14 +25,6 @@ export const config = [
],
},
},
{
plugins: {
turbo: turboPlugin,
},
rules: {
"turbo/no-undeclared-env-vars": "warn",
},
},
{
ignores: ["dist/**"],
},
Expand Down
12 changes: 0 additions & 12 deletions packages/eslint/eslint.js

This file was deleted.

64 changes: 34 additions & 30 deletions packages/eslint/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
];
1 change: 0 additions & 1 deletion packages/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
50 changes: 27 additions & 23 deletions packages/eslint/react-internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
];

0 comments on commit 380d95c

Please sign in to comment.