Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GSTJ committed May 13, 2023
1 parent 8f15cdf commit 4dc1bcf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"linting",
"code quality"
],
"version": "1.0.12",
"version": "1.1.0",
"main": "lib/index.js",
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated && npm run build",
Expand Down
6 changes: 6 additions & 0 deletions src/rules/jsx-explicit-boolean.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ruleTester.run("jsx-explicit-boolean", require("./jsx-explicit-boolean"), {

// Rest
{ code: "const a = true; a && <div />;" },
{ code: "const a = true; const b = a; b && <div />;" },
{ code: "const a = false; a && <div />;" },
{ code: "const a = true; Boolean(a) && <div />;" },
{ code: "const a = false; Boolean(a) && <div />;" },
Expand Down Expand Up @@ -143,5 +144,10 @@ ruleTester.run("jsx-explicit-boolean", require("./jsx-explicit-boolean"), {
output:
"const a = 1; const b = '0'; const c = 0; <View>{Boolean(a && !!b && !!c) && <Text />}</View>;",
},
{
code: "const a = undefined; a && <div />;",
errors: [{ messageId: "booleanConversion" }],
output: "const a = undefined; Boolean(a) && <div />;",
},
],
});
2 changes: 1 addition & 1 deletion src/rules/jsx-explicit-boolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function checkBooleanValidity(node, context) {
return variable.defs.some(
(def) =>
def.type === "Variable" &&
typeof def.node.init?.value === "boolean"
checkBooleanValidity(def.node.init, context)
);
}
scope = scope.upper;
Expand Down

0 comments on commit 4dc1bcf

Please sign in to comment.