Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Rel1cx/eslint-react
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.37.1
Choose a base ref
...
head repository: Rel1cx/eslint-react
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.37.2
Choose a head ref
  • 6 commits
  • 30 files changed
  • 1 contributor

Commits on Mar 22, 2025

  1. refactor: remove duplicate code

    Rel1cx committed Mar 22, 2025
    Copy the full SHA
    d281f86 View commit details
  2. release: 1.37.2-next.0

    Rel1cx committed Mar 22, 2025
    Copy the full SHA
    36f0c82 View commit details
  3. fix: prefer-read-only-props false positive using React types, closes

    Rel1cx authored Mar 22, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    873816a View commit details
  4. release: 1.37.2-next.1

    Rel1cx committed Mar 22, 2025
    Copy the full SHA
    60e0fd2 View commit details
  5. release: 1.37.2-beta.1

    Rel1cx committed Mar 22, 2025
    Copy the full SHA
    42c13a5 View commit details
  6. release: 1.37.2

    Rel1cx committed Mar 22, 2025
    Copy the full SHA
    95996b1 View commit details
Showing with 446 additions and 381 deletions.
  1. +3 −1 .pkgs/eslint-plugin-local/dist/index.d.ts
  2. +80 −77 .pkgs/eslint-plugin-local/dist/index.js
  3. +16 −13 .pkgs/eslint-plugin-local/src/rules/avoid-multiline-template-expression.ts
  4. +18 −15 .pkgs/eslint-plugin-local/src/rules/no-shadow-underscore.ts
  5. +67 −60 .pkgs/eslint-plugin-local/src/rules/prefer-eqeq-nullish-comparison.ts
  6. +8 −0 CHANGELOG.md
  7. +1 −1 VERSION
  8. +8 −0 apps/website/content/docs/changelog.md
  9. +1 −1 package.json
  10. +1 −1 packages/core/package.json
  11. +1 −1 packages/plugins/eslint-plugin-react-debug/package.json
  12. +1 −1 packages/plugins/eslint-plugin-react-dom/package.json
  13. +54 −52 packages/plugins/eslint-plugin-react-dom/src/rules/no-hydrate.ts
  14. +54 −52 packages/plugins/eslint-plugin-react-dom/src/rules/no-render.ts
  15. +54 −52 packages/plugins/eslint-plugin-react-dom/src/rules/no-use-form-state.ts
  16. +1 −1 packages/plugins/eslint-plugin-react-hooks-extra/package.json
  17. +1 −1 packages/plugins/eslint-plugin-react-naming-convention/package.json
  18. +1 −1 packages/plugins/eslint-plugin-react-web-api/package.json
  19. +2 −1 packages/plugins/eslint-plugin-react-x/package.json
  20. +1 −12 packages/plugins/eslint-plugin-react-x/src/rules/no-children-map.ts
  21. +1 −28 packages/plugins/eslint-plugin-react-x/src/rules/no-comment-textnodes.ts
  22. +23 −0 packages/plugins/eslint-plugin-react-x/src/rules/prefer-read-only-props.spec.ts
  23. +14 −2 packages/plugins/eslint-plugin-react-x/src/rules/prefer-read-only-props.ts
  24. +1 −1 packages/plugins/eslint-plugin/package.json
  25. +1 −1 packages/shared/package.json
  26. +1 −1 packages/utilities/ast/package.json
  27. +1 −1 packages/utilities/eff/package.json
  28. +1 −1 packages/utilities/jsx/package.json
  29. +1 −1 packages/utilities/var/package.json
  30. +29 −2 pnpm-lock.yaml
4 changes: 3 additions & 1 deletion .pkgs/eslint-plugin-local/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';

type MessageID = "unexpectedComparison" | "useLooseComparisonSuggestion";

declare const _default: {
readonly meta: {
readonly name: string;
@@ -8,7 +10,7 @@ declare const _default: {
readonly rules: {
readonly "avoid-multiline-template-expression": _typescript_eslint_utils_ts_eslint.RuleModule<"avoidMultilineTemplateExpression", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
readonly "no-shadow-underscore": _typescript_eslint_utils_ts_eslint.RuleModule<"noShadowUnderscore", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
readonly "prefer-eqeq-nullish-comparison": _typescript_eslint_utils_ts_eslint.RuleModule<"unexpectedComparison" | "useLooseComparisonSuggestion", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
readonly "prefer-eqeq-nullish-comparison": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
};
};

157 changes: 80 additions & 77 deletions .pkgs/eslint-plugin-local/dist/index.js
Original file line number Diff line number Diff line change
@@ -63,20 +63,21 @@ var avoid_multiline_template_expression_default = createRule({
schema: []
},
name: RULE_NAME,
create(context) {
return {
TemplateLiteral: (node) => {
if (AST.isMultiLine(node)) {
context.report({
messageId: "avoidMultilineTemplateExpression",
node
});
}
}
};
},
create,
defaultOptions: []
});
function create(context) {
return {
TemplateLiteral: (node) => {
if (AST.isMultiLine(node)) {
context.report({
messageId: "avoidMultilineTemplateExpression",
node
});
}
}
};
}

// src/rules/no-shadow-underscore.ts
var RULE_NAME2 = "no-shadow-underscore";
@@ -94,22 +95,23 @@ var no_shadow_underscore_default = createRule({
schema: []
},
name: RULE_NAME2,
create(context) {
return {
"Identifier[name='_']"(node) {
const initialScope = context.sourceCode.getScope(node);
const isFromImport = isInitializedFromSource("_", "@eslint-react/eff", initialScope);
if (!isFromImport) {
context.report({
messageId: "noShadowUnderscore",
node
});
}
}
};
},
create: create2,
defaultOptions: []
});
function create2(context) {
return {
"Identifier[name='_']"(node) {
const initialScope = context.sourceCode.getScope(node);
const isFromImport = isInitializedFromSource("_", "@eslint-react/eff", initialScope);
if (!isFromImport) {
context.report({
messageId: "noShadowUnderscore",
node
});
}
}
};
}
var RULE_NAME3 = "prefer-eqeq-nullish-comparison";
var prefer_eqeq_nullish_comparison_default = createRule({
meta: {
@@ -126,59 +128,60 @@ var prefer_eqeq_nullish_comparison_default = createRule({
schema: []
},
name: RULE_NAME3,
create(context) {
return {
BinaryExpression(node) {
if (node.operator === "===" || node.operator === "!==") {
const offendingChild = [node.left, node.right].find(
(child) => child.type === AST_NODE_TYPES.Identifier && child.name === "undefined" || child.type === AST_NODE_TYPES.Literal && child.raw === "null"
);
if (offendingChild == null) {
return;
}
const operatorToken = nullThrows(
context.sourceCode.getFirstTokenBetween(
node.left,
node.right,
(token) => token.value === node.operator
),
NullThrowsReasons.MissingToken(node.operator, "binary expression")
);
const wasLeft = node.left === offendingChild;
const nullishKind = offendingChild.type === AST_NODE_TYPES.Identifier ? "undefined" : "null";
const looseOperator = node.operator === "===" ? "==" : "!=";
context.report({
messageId: "unexpectedComparison",
data: {
nullishKind,
strictOperator: node.operator
},
loc: wasLeft ? {
end: operatorToken.loc.end,
start: node.left.loc.start
} : {
end: node.right.loc.end,
start: operatorToken.loc.start
},
suggest: [
{
messageId: "useLooseComparisonSuggestion",
data: {
looseOperator
},
fix: (fixer) => [
fixer.replaceText(offendingChild, "null"),
fixer.replaceText(operatorToken, looseOperator)
]
}
]
});
}
}
};
},
create: create3,
defaultOptions: []
});
function create3(context) {
return {
BinaryExpression(node) {
if (node.operator === "===" || node.operator === "!==") {
const offendingChild = [node.left, node.right].find(
(child) => child.type === AST_NODE_TYPES.Identifier && child.name === "undefined" || child.type === AST_NODE_TYPES.Literal && child.raw === "null"
);
if (offendingChild == null) {
return;
}
const operatorToken = nullThrows(
context.sourceCode.getFirstTokenBetween(
node.left,
node.right,
(token) => token.value === node.operator
),
NullThrowsReasons.MissingToken(node.operator, "binary expression")
);
const wasLeft = node.left === offendingChild;
const nullishKind = offendingChild.type === AST_NODE_TYPES.Identifier ? "undefined" : "null";
const looseOperator = node.operator === "===" ? "==" : "!=";
context.report({
messageId: "unexpectedComparison",
data: {
nullishKind,
strictOperator: node.operator
},
loc: wasLeft ? {
end: operatorToken.loc.end,
start: node.left.loc.start
} : {
end: node.right.loc.end,
start: operatorToken.loc.start
},
suggest: [
{
messageId: "useLooseComparisonSuggestion",
data: {
looseOperator
},
fix: (fixer) => [
fixer.replaceText(offendingChild, "null"),
fixer.replaceText(operatorToken, looseOperator)
]
}
]
});
}
}
};
}

// src/index.ts
var index_default = {
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as AST from "@eslint-react/ast";
import type { RuleFeature } from "@eslint-react/shared";
import type { RuleContext, RuleFeature } from "@eslint-react/shared";
import type { RuleListener } from "@typescript-eslint/utils/ts-eslint";
import type { CamelCase } from "string-ts";

import { createRule } from "../utils";
@@ -23,17 +24,19 @@ export default createRule<[], MessageID>({
schema: [],
},
name: RULE_NAME,
create(context) {
return {
TemplateLiteral: (node) => {
if (AST.isMultiLine(node)) {
context.report({
messageId: "avoidMultilineTemplateExpression",
node,
});
}
},
};
},
create,
defaultOptions: [],
});

export function create(context: RuleContext<MessageID, []>): RuleListener {
return {
TemplateLiteral: (node) => {
if (AST.isMultiLine(node)) {
context.report({
messageId: "avoidMultilineTemplateExpression",
node,
});
}
},
};
}
33 changes: 18 additions & 15 deletions .pkgs/eslint-plugin-local/src/rules/no-shadow-underscore.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { RuleFeature } from "@eslint-react/shared";
import type { RuleContext, RuleFeature } from "@eslint-react/shared";

Check warning on line 1 in .pkgs/eslint-plugin-local/src/rules/no-shadow-underscore.ts

GitHub Actions / check

Run autofix to sort these imports!

Check warning on line 1 in .pkgs/eslint-plugin-local/src/rules/no-shadow-underscore.ts

GitHub Actions / Publish

Run autofix to sort these imports!
import type { TSESTree } from "@typescript-eslint/types";
import type { CamelCase } from "string-ts";

import { createRule, isInitializedFromSource } from "../utils";
import type { RuleListener } from "@typescript-eslint/utils/ts-eslint";

export const RULE_NAME = "no-shadow-underscore";

@@ -23,19 +24,21 @@ export default createRule<[], MessageID>({
schema: [],
},
name: RULE_NAME,
create(context) {
return {
"Identifier[name='_']"(node: TSESTree.Identifier & { name: "_" }) {
const initialScope = context.sourceCode.getScope(node);
const isFromImport = isInitializedFromSource("_", "@eslint-react/eff", initialScope);
if (!isFromImport) {
context.report({
messageId: "noShadowUnderscore",
node,
});
}
},
};
},
create,
defaultOptions: [],
});

export function create(context: RuleContext<MessageID, []>): RuleListener {
return {
"Identifier[name='_']"(node: TSESTree.Identifier & { name: "_" }) {
const initialScope = context.sourceCode.getScope(node);
const isFromImport = isInitializedFromSource("_", "@eslint-react/eff", initialScope);
if (!isFromImport) {
context.report({
messageId: "noShadowUnderscore",
node,
});
}
},
};
}
Loading