Skip to content

Commit

Permalink
Enable unicorn/prefer-logical-operator-over-ternary rule (prettier#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored and medikoo committed Jan 4, 2024
1 parent e3e1f56 commit 4b82672
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 20 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ module.exports = {
"unicorn/prefer-array-some": "error",
"unicorn/prefer-includes": "error",
"unicorn/prefer-json-parse-buffer": "error",
"unicorn/prefer-logical-operator-over-ternary": "error",
"unicorn/prefer-native-coercion-functions": "error",
"unicorn/prefer-number-properties": "error",
"unicorn/prefer-optional-catch-binding": "error",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"eslint-plugin-prettier-internal-rules": "2.0.1",
"eslint-plugin-react": "7.29.4",
"eslint-plugin-regexp": "1.7.0",
"eslint-plugin-unicorn": "42.0.0",
"eslint-plugin-unicorn": "43.0.0",
"esm-utils": "3.0.0",
"execa": "6.1.0",
"jest": "27.5.1",
Expand Down
12 changes: 3 additions & 9 deletions src/language-css/parser-postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ function parseNestedCSS(node, options) {

if (typeof node.selector === "string") {
selector = node.raws.selector
? node.raws.selector.scss
? node.raws.selector.scss
: node.raws.selector.raw
? node.raws.selector.scss ?? node.raws.selector.raw
: node.selector;

if (node.raws.between && node.raws.between.trim().length > 0) {
Expand All @@ -322,9 +320,7 @@ function parseNestedCSS(node, options) {

if (typeof node.value === "string") {
value = node.raws.value
? node.raws.value.scss
? node.raws.value.scss
: node.raws.value.raw
? node.raws.value.scss ?? node.raws.value.raw
: node.value;

value = value.trim();
Expand All @@ -336,9 +332,7 @@ function parseNestedCSS(node, options) {

if (typeof node.params === "string") {
params = node.raws.params
? node.raws.params.scss
? node.raws.params.scss
: node.raws.params.raw
? node.raws.params.scss ?? node.raws.params.raw
: node.params;

if (node.raws.afterName && node.raws.afterName.trim().length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/language-css/printer-postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function genericPrint(path, options, print) {
? [node.namespace === true ? "" : node.namespace.trim(), "|"]
: "",
node.attribute.trim(),
node.operator ? node.operator : "",
node.operator ?? "",
node.value
? quoteAttributeValue(
adjustStrings(node.value.trim(), options),
Expand Down
28 changes: 19 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,16 @@
dependencies:
"@babel/types" "^7.16.7"

"@babel/helper-validator-identifier@^7.15.7", "@babel/helper-validator-identifier@^7.16.7":
"@babel/helper-validator-identifier@^7.16.7":
version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.16.7.tgz#e8c602438c4a8195751243da9031d1607d247cad"
integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==

"@babel/helper-validator-identifier@^7.18.6":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.18.6.tgz#9c97e30d31b2b8c72a1d08984f2ca9b574d7a076"
integrity sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==

"@babel/helper-validator-option@^7.16.7":
version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz#b203ce62ce5fe153899b617c08957de860de4d23"
Expand Down Expand Up @@ -2277,11 +2282,16 @@ character-reference-invalid@^1.0.0:
resolved "https://registry.yarnpkg.com/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz#083329cda0eae272ab3dbbf37e9a382c13af1560"
integrity sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==

ci-info@3.3.0, ci-info@^3.2.0, ci-info@^3.3.0:
ci-info@3.3.0, ci-info@^3.2.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.0.tgz#b4ed1fb6818dea4803a55c623041f9165d2066b2"
integrity sha512-riT/3vI5YpVH6/qomlDnJow6TBee2PBKSEpx3O32EGPYbWGIRsIlGRms3Sm74wYE1JMo8RnO04Hb12+v1J5ICw==

ci-info@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.3.2.tgz#6d2967ffa407466481c6c90b6e16b3098f080128"
integrity sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg==

cjk-regex@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/cjk-regex/-/cjk-regex-2.0.1.tgz#98cca187aa67931db14f0d9dde556150c8116d95"
Expand Down Expand Up @@ -3122,13 +3132,13 @@ eslint-plugin-regexp@1.7.0:
regexpp "^3.2.0"
scslre "^0.1.6"

eslint-plugin-unicorn@42.0.0:
version "42.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-42.0.0.tgz#47d60c00c263ad743403b052db689e39acbacff1"
integrity sha512-ixBsbhgWuxVaNlPTT8AyfJMlhyC5flCJFjyK3oKE8TRrwBnaHvUbuIkCM1lqg8ryYrFStL/T557zfKzX4GKSlg==
eslint-plugin-unicorn@43.0.0:
version "43.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-unicorn/-/eslint-plugin-unicorn-43.0.0.tgz#c26fdfd146036b3f7951fa0f8c9af2b81bd87096"
integrity sha512-Z/6HX8yry+zAjo4jHHTAbe1rfniox7qgmCReGBfTc/CVgotfScaMCc4dtSSTHlJ+7Yix5o6LPXzwwpuGGFricg==
dependencies:
"@babel/helper-validator-identifier" "^7.15.7"
ci-info "^3.3.0"
"@babel/helper-validator-identifier" "^7.18.6"
ci-info "^3.3.2"
clean-regexp "^1.0.0"
eslint-utils "^3.0.0"
esquery "^1.4.0"
Expand All @@ -3139,7 +3149,7 @@ eslint-plugin-unicorn@42.0.0:
read-pkg-up "^7.0.1"
regexp-tree "^0.1.24"
safe-regex "^2.1.1"
semver "^7.3.5"
semver "^7.3.7"
strip-indent "^3.0.0"

eslint-scope@^5.1.1:
Expand Down

0 comments on commit 4b82672

Please sign in to comment.