Skip to content

Commit 3557ab5

Browse files
committed
chore: add eslint-plugin-de-morgan and update linting scripts
1 parent 0e0d134 commit 3557ab5

File tree

10 files changed

+44
-19
lines changed

10 files changed

+44
-19
lines changed

apps/website/eslint.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import eslintJs from "@eslint/js";
22
import eslintReact from "@eslint-react/eslint-plugin";
33
import eslintMarkdown from "@eslint/markdown";
4+
import eslintPluginDeMorgan from "eslint-plugin-de-morgan";
45
import eslintPluginMdx from "eslint-plugin-mdx";
56
import eslintPluginNext from "@next/eslint-plugin-next";
7+
import eslintPluginPerfectionist from "eslint-plugin-perfectionist";
68
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
79
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
8-
import eslintPluginPerfectionist from "eslint-plugin-perfectionist";
910
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
1011
import eslintPluginUnicorn from "eslint-plugin-unicorn";
1112
import tseslint from "typescript-eslint";
@@ -72,6 +73,7 @@ export default tseslint.config(
7273
extends: [
7374
eslintJs.configs.recommended,
7475
tseslint.configs.recommended,
76+
eslintPluginDeMorgan.configs.recommended,
7577
eslintPluginPerfectionist.configs["recommended-natural"],
7678
],
7779
plugins: {

apps/website/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"scripts": {
66
"build": "next build",
77
"dev": "next dev",
8+
"lint": "pnpm run lint:ts && pnpm run lint:type",
89
"lint:markup": "markuplint \"**/*.{jsx,tsx}\"",
910
"lint:ts": "eslint .",
10-
"prepare": "fumadocs-mdx",
11+
"lint:type": "tsc --noEmit",
12+
"prepare": "fumadocs-mdx && pnpm run build",
1113
"start": "next start"
1214
},
1315
"dependencies": {
@@ -45,6 +47,7 @@
4547
"autoprefixer": "^10.4.20",
4648
"dedent": "^1.5.3",
4749
"eslint": "^9.20.1",
50+
"eslint-plugin-de-morgan": "^1.0.0",
4851
"eslint-plugin-import-x": "^4.6.1",
4952
"eslint-plugin-mdx": "^3.1.5",
5053
"eslint-plugin-perfectionist": "^4.8.0",

eslint.config.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import url from "node:url";
55
import eslintJs from "@eslint/js";
66
import eslintMarkdown from "@eslint/markdown";
77
import eslintStylistic from "@stylistic/eslint-plugin";
8+
import eslintConfigFlatGitignore from "eslint-config-flat-gitignore";
9+
import eslintPluginDeMorgan from "eslint-plugin-de-morgan";
810
import eslintPluginJsdoc from "eslint-plugin-jsdoc";
911
import eslintPluginLocal from "@local/eslint-plugin-local";
1012
import eslintPluginPerfectionist from "eslint-plugin-perfectionist";
1113
import eslintPluginRegexp from "eslint-plugin-regexp";
1214
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
1315
import eslintPluginUnicorn from "eslint-plugin-unicorn";
1416
import eslintPluginVitest from "eslint-plugin-vitest";
15-
import eslintConfigFlatGitignore from "eslint-config-flat-gitignore";
1617
import tseslint from "typescript-eslint";
1718

1819
const dirname = url.fileURLToPath(new URL(".", import.meta.url));
@@ -28,6 +29,13 @@ const GLOB_TEST = [
2829
// const GLOB_YAML = ["*.{yaml,yml}", "**/*.{yaml,yml}"];
2930
const GLOB_CONFIG = ["*.config.{ts,tsx,cts,mts}", "**/*.config.{ts,tsx,cts,mts}"];
3031
const GLOB_SCRIPT = ["scripts/**/*.{ts,cts,mts}"];
32+
const GLOB_IGNORES = [
33+
...eslintConfigFlatGitignore().ignores,
34+
"apps",
35+
"docs",
36+
"test",
37+
"examples",
38+
];
3139

3240
const templateIndentAnnotations = [
3341
"outdent",
@@ -83,7 +91,10 @@ const enableTypeCheckedRules = {
8391
const disableTypeCheckedRules = Object.fromEntries(Object.keys(enableTypeCheckedRules).map((x) => [x, "off"]));
8492

8593
export default tseslint.config(
86-
eslintConfigFlatGitignore(),
94+
{
95+
name: "global-ignores",
96+
ignores: GLOB_IGNORES,
97+
},
8798
{
8899
extends: [
89100
eslintMarkdown.configs.recommended,
@@ -98,20 +109,12 @@ export default tseslint.config(
98109
"markdown/no-missing-label-refs": "off",
99110
},
100111
},
101-
{
102-
name: "global-ignores",
103-
ignores: [
104-
"apps",
105-
"docs",
106-
"test",
107-
"examples",
108-
],
109-
},
110112
{
111113
files: [...GLOB_JS, ...GLOB_TS],
112114
extends: [
113115
eslintJs.configs.recommended,
114116
...tseslint.configs.strict,
117+
eslintPluginDeMorgan.configs.recommended,
115118
eslintPluginPerfectionist.configs["recommended-natural"],
116119
eslintPluginRegexp.configs["flat/recommended"],
117120
eslintPluginJsdoc.configs["flat/recommended-typescript-error"],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"esbuild": "^0.25.0",
7979
"eslint": "^9.20.1",
8080
"eslint-config-flat-gitignore": "^2.0.0",
81+
"eslint-plugin-de-morgan": "^1.0.0",
8182
"eslint-plugin-jsdoc": "^50.6.3",
8283
"eslint-plugin-perfectionist": "^4.8.0",
8384
"eslint-plugin-regexp": "^2.7.0",

packages/plugins/eslint-plugin-react-hooks-extra/src/utils/is-from-use-state-call.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { isFromHookCall } from "./is-from-hook-call";
77
export function isFromUseStateCall(context: RuleContext, settings: ESLintReactSettingsNormalized) {
88
const predicate = (topLevelId: TSESTree.Identifier, call: TSESTree.CallExpression) => {
99
const { parent } = call;
10-
if (!("id" in parent && parent.id?.type === T.ArrayPattern)) {
10+
if (!("id" in parent) || parent.id?.type !== T.ArrayPattern) {
1111
return true;
1212
}
1313
return parent.id.elements.findIndex((e) => e?.type === T.Identifier && e.name === topLevelId.name) === 1;

packages/plugins/eslint-plugin-react-x/src/rules/no-access-state-in-setstate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default createRule<[], MessageID>({
134134
return;
135135
}
136136
// detect `{ foo, state: baz } = this`
137-
if (!(node.init != null && AST.isThisExpression(node.init) && node.id.type === T.ObjectPattern)) {
137+
if (node.init == null || !AST.isThisExpression(node.init) || node.id.type !== T.ObjectPattern) {
138138
return;
139139
}
140140
const hasState = node

packages/plugins/eslint-plugin-react-x/src/rules/no-unused-state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export default createRule<[], MessageID>({
175175
return;
176176
}
177177
// detect `{ foo, state: baz } = this`
178-
if (!(node.init != null && AST.isThisExpression(node.init) && node.id.type === T.ObjectPattern)) {
178+
if (node.init == null || !AST.isThisExpression(node.init) || node.id.type !== T.ObjectPattern) {
179179
return;
180180
}
181181
const hasState = node.id.properties.some((prop) => {

packages/plugins/eslint-plugin-react-x/src/rules/no-useless-fragment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function checkAndReport(
4444
) {
4545
function fix(fixer: RuleFixer) {
4646
// Not safe to fix fragments without a jsx parent.
47-
if (!(node.parent.type === T.JSXElement || node.parent.type === T.JSXFragment)) {
47+
if (node.parent.type !== T.JSXElement && node.parent.type !== T.JSXFragment) {
4848
// const a = <></>
4949
if (node.children.length === 0) {
5050
return null;

packages/utilities/var/src/value-construction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function getValueConstruction(
8181
return getValueConstruction(node.alternate, initialScope, hint);
8282
}
8383
case T.Identifier: {
84-
if (!("name" in node && typeof node.name === "string")) {
84+
if (!("name" in node) || typeof node.name !== "string") {
8585
return _;
8686
}
8787
const variable = initialScope.set.get(node.name);
@@ -95,7 +95,7 @@ export function getValueConstruction(
9595
return _;
9696
}
9797
default: {
98-
if (!("expression" in node && typeof node.expression === "object")) {
98+
if (!("expression" in node) || typeof node.expression !== "object") {
9999
return _;
100100
}
101101
return getValueConstruction(node.expression, initialScope, hint);

pnpm-lock.yaml

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)