Skip to content

Commit

Permalink
4.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ftzi committed Nov 28, 2024
1 parent e4026a6 commit 57b5246
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 59 deletions.
5 changes: 4 additions & 1 deletion next.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
extends: ["next/core-web-vitals", "next/typescript", "./react.js"],
extends: ["next/core-web-vitals", "next/typescript", "./ts.js"],
rules: {
...require("./shared-react.js"),
},
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "eslint-config-gev",
"version": "4.6.0",
"version": "4.6.1",
"description": "Curated ESLint configs for TS, JS, Next, React, and React Native projects",
"author": "SrBrahma",
"main": "index.js",
"bin": "bin.js",
"scripts": {
"format": "biome check --apply-unsafe . && eslint --fix . package.json",
"format:check": "biome check . && eslint . package.json",
"format": "biome check --unsafe --fix . && eslint --fix . package.json",
"format:check": "biome check --unsafe . && eslint . package.json",
"pre-commit": "bun format && bun start && git add -A",
"prepare": "bunx husky",
"start": "bun scripts/makeTsExtensions.ts",
Expand Down Expand Up @@ -38,23 +38,23 @@
"citty": "0.1.6",
"eslint": "8.56.0",
"eslint-config-biome": "^1.9.3",
"eslint-config-next": "^15.0.3",
"eslint-plugin-jsdoc": "48.2.6",
"eslint-plugin-json-files": "^4.4.2",
"eslint-plugin-no-autofix": "2.1.0",
"eslint-plugin-no-relative-import-paths": "1.5.5",
"eslint-plugin-prefer-arrow-functions": "3.4.1",
"eslint-plugin-react": "7.37.2",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-native": "4.1.0",
"eslint-plugin-react-refresh": "^0.4.14",
"eslint-plugin-require-extensions": "0.1.3",
"eslint-plugin-unused-imports": "3.2.0"
},
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@sindresorhus/tsconfig": "7.0.0",
"@types/bun": "^1.1.14",
"eslint-config-next": "^15.0.3",
"eslint-plugin-react-refresh": "^0.4.14",
"husky": "9.1.7"
}
}
53 changes: 1 addition & 52 deletions react.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,6 @@ module.exports = {
"./ts.js",
],
rules: {
"react/prop-types": "off",
"react/display-name": "off",

/**
* Allow to use <Component children={x}/>. Sometimes it's useful to simplify the code and to do some nice hacks,
* like conditional wrapping component.
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-children-prop.md
*/
"react/no-children-prop": "off",

/**
* Enable deps autofix. I've only had infinite loops once, and the autofix was off,
* I just accept the suggestions and don't spend time analysing it. Rare to happen, easy to notice.
*
* https://github.com/facebook/react/issues/18235#issuecomment-898636301
*/
"react-hooks/exhaustive-deps": [
"warn",
{
enableDangerousAutofixThisMayCauseInfiniteLoops: true,
},
],
/** https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md */
// Dropped it as it won't allow <></> to fit JSX.Element return.
// "react/jsx-no-useless-fragment": ["warn", {"allowExpressions": true}],

/**
* From <A b={'c'}>d</A> to <A b="c">{'d'}<A/>
*
* Note that it always converts to double-quotes when changing,
* so we use `jsx-quotes` rule for props and `quotes` rule for children.
*
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
*/
"react/jsx-curly-brace-presence": [
"warn",
{ props: "never", children: "always" },
],

/**
* Prefer <> over <React.Fragment> if not using key=''.
*
* https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
*/
"react/jsx-fragments": "warn",

/** https://www.npmjs.com/package/eslint-plugin-react-refresh */
"react-refresh/only-export-components": [
"warn",
// Only Vite supports this.
{ allowConstantExport: true },
],
...require("./shared-react.js"),
},
}
46 changes: 46 additions & 0 deletions shared-react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = {
"react/prop-types": "off",
"react/display-name": "off",
/**
* Enable deps autofix. I've only had infinite loops once, and the autofix was off,
* I just accept the suggestions and don't spend time analysing it. Rare to happen, easy to notice.
*
* https://github.com/facebook/react/issues/18235#issuecomment-898636301
*/
"react-hooks/exhaustive-deps": [
"warn",
{
enableDangerousAutofixThisMayCauseInfiniteLoops: true,
},
],
/** https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md */
// Dropped it as it won't allow <></> to fit JSX.Element return.
// "react/jsx-no-useless-fragment": ["warn", {"allowExpressions": true}],

/**
* From <A b={'c'}>d</A> to <A b="c">{'d'}<A/>
*
* Note that it always converts to double-quotes when changing,
* so we use `jsx-quotes` rule for props and `quotes` rule for children.
*
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md
*/
"react/jsx-curly-brace-presence": [
"warn",
{ props: "never", children: "always" },
],

/**
* Prefer <> over <React.Fragment> if not using key=''.
*
* https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md
*/
"react/jsx-fragments": "warn",

/** https://www.npmjs.com/package/eslint-plugin-react-refresh */
"react-refresh/only-export-components": [
"warn",
// Only Vite supports this.
{ allowConstantExport: true },
],
}
19 changes: 19 additions & 0 deletions tests/test.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { test } from "bun:test"
import path from "node:path"
import { $ } from "bun"

const flavors = ["index", "ts", "js", "react", "react-native"]

$.cwd(path.resolve(__dirname))

test("can run eslint", async () => {
const execs = flavors.map((flavor) =>
$`bunx eslint --config ../${flavor}.js test.test.ts`.catch(
(err: unknown) => {
throw new Error(`error on flavor ${flavor}: ${err}`)
},
),
)

await Promise.all(execs)
})
3 changes: 3 additions & 0 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@sindresorhus/tsconfig"
}

0 comments on commit 57b5246

Please sign in to comment.