From 4dc1bcf66ea3ba0ba6dc52f67bf380d168cb945e Mon Sep 17 00:00:00 2001 From: Gabriel Taveira Date: Sat, 13 May 2023 12:10:07 -0300 Subject: [PATCH] v1.1.0 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/rules/jsx-explicit-boolean.test.tsx | 6 ++++++ src/rules/jsx-explicit-boolean.ts | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..03a962f --- /dev/null +++ b/CHANGELOG.md @@ -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). diff --git a/package.json b/package.json index ee38c18..192bdf4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/rules/jsx-explicit-boolean.test.tsx b/src/rules/jsx-explicit-boolean.test.tsx index 652a795..53ed2d7 100644 --- a/src/rules/jsx-explicit-boolean.test.tsx +++ b/src/rules/jsx-explicit-boolean.test.tsx @@ -31,6 +31,7 @@ ruleTester.run("jsx-explicit-boolean", require("./jsx-explicit-boolean"), { // Rest { code: "const a = true; a &&
;" }, + { code: "const a = true; const b = a; b &&
;" }, { code: "const a = false; a &&
;" }, { code: "const a = true; Boolean(a) &&
;" }, { code: "const a = false; Boolean(a) &&
;" }, @@ -143,5 +144,10 @@ ruleTester.run("jsx-explicit-boolean", require("./jsx-explicit-boolean"), { output: "const a = 1; const b = '0'; const c = 0; {Boolean(a && !!b && !!c) && };", }, + { + code: "const a = undefined; a &&
;", + errors: [{ messageId: "booleanConversion" }], + output: "const a = undefined; Boolean(a) &&
;", + }, ], }); diff --git a/src/rules/jsx-explicit-boolean.ts b/src/rules/jsx-explicit-boolean.ts index f1147cc..033f7d5 100644 --- a/src/rules/jsx-explicit-boolean.ts +++ b/src/rules/jsx-explicit-boolean.ts @@ -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;