Replace logical-assignment-operators with the one from unicorn (#19391)
This commit is contained in:
1 parent
cf00244e01
commit
638e4b82c0
7 files changed
+19
-31
No files matched your search
+6
-3
@@ -63,7 +63,6 @@ const configs = [
|
||||
curly: "error",
|
||||
"dot-notation": "error",
|
||||
eqeqeq: "error",
|
||||
"logical-assignment-operators": "error",
|
||||
"no-console": isCI ? "error" : "warn",
|
||||
"no-constant-binary-expression": "error",
|
||||
"no-duplicate-imports": "error",
|
||||
@@ -250,7 +249,11 @@ const configs = [
|
||||
"unicorn/escape-case": "off",
|
||||
"unicorn/filename-case": ["error", { checkDirectories: false }],
|
||||
"unicorn/import-style": "off",
|
||||
"unicorn/logical-assignment-operators": "off",
|
||||
"unicorn/logical-assignment-operators": [
|
||||
"error",
|
||||
"always",
|
||||
{ enforceForIfStatements: true },
|
||||
],
|
||||
"unicorn/max-nested-calls": "off",
|
||||
"unicorn/no-array-callback-reference": "off",
|
||||
"unicorn/no-array-method-this-argument": "off",
|
||||
@@ -419,7 +422,7 @@ const configs = [
|
||||
files: ["tests/**/*.{js,cjs}"],
|
||||
rules: {
|
||||
// TODO: Enable this when we drop support for Node.js v14
|
||||
"logical-assignment-operators": "off",
|
||||
"unicorn/logical-assignment-operators": "off",
|
||||
"unicorn/prefer-array-flat": "off",
|
||||
"unicorn/prefer-array-flat-map": "off",
|
||||
"unicorn/prefer-string-replace-all": "off",
|
||||
|
||||
@@ -61,9 +61,7 @@ class Node {
|
||||
if (nodes) {
|
||||
const mappedNodes = mapNodesIfChanged(nodes, (node) => node.map(fn));
|
||||
if (newNode !== nodes) {
|
||||
if (!newNode) {
|
||||
newNode = new Node({ parent: this.parent });
|
||||
}
|
||||
newNode ??= new Node({ parent: this.parent });
|
||||
newNode.setProperty(NODES_KEY, mappedNodes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,11 +244,9 @@ function getFencedCodeBlockValue(node, originalText) {
|
||||
function mapAst(ast, handler) {
|
||||
return (function preorder(node, index, parentStack) {
|
||||
const newNode = { ...handler(node, index, parentStack) };
|
||||
if (newNode.children) {
|
||||
newNode.children = newNode.children.map((child, index) =>
|
||||
preorder(child, index, [newNode, ...parentStack]),
|
||||
);
|
||||
}
|
||||
newNode.children &&= newNode.children.map((child, index) =>
|
||||
preorder(child, index, [newNode, ...parentStack]),
|
||||
);
|
||||
|
||||
return newNode;
|
||||
})(ast, null, []);
|
||||
|
||||
@@ -50,9 +50,7 @@ function getFrontMatter(text) {
|
||||
);
|
||||
|
||||
let language = explicitLanguage;
|
||||
if (!language) {
|
||||
language = startDelimiter === "+++" ? "toml" : "yaml";
|
||||
}
|
||||
language ||= startDelimiter === "+++" ? "toml" : "yaml";
|
||||
|
||||
if (
|
||||
endDelimiterIndex === -1 &&
|
||||
|
||||
@@ -83,9 +83,7 @@ async function normalizeFormatOptions(options, opts = {}) {
|
||||
const mixedDefaults = { ...defaults, ...pluginDefaults };
|
||||
|
||||
for (const [k, value] of Object.entries(mixedDefaults)) {
|
||||
if (rawOptions[k] === null || rawOptions[k] === undefined) {
|
||||
rawOptions[k] = value;
|
||||
}
|
||||
rawOptions[k] ??= value;
|
||||
}
|
||||
|
||||
if (rawOptions.parser === "json") {
|
||||
|
||||
+3
-6
@@ -31,12 +31,9 @@ function handleParseError(error, text) {
|
||||
// We use 1-based column, but `@babel/code-frame` uses 0-based column
|
||||
// https://github.com/babel/babel/pull/17849
|
||||
let { start, end } = loc;
|
||||
if (start) {
|
||||
start = { line: start.line, column: start.column - 1 };
|
||||
}
|
||||
if (end) {
|
||||
end = { line: end.line, column: end.column - 1 };
|
||||
}
|
||||
|
||||
start &&= { line: start.line, column: start.column - 1 };
|
||||
end &&= { line: end.line, column: end.column - 1 };
|
||||
|
||||
const codeFrame = codeFrameColumns(
|
||||
text,
|
||||
|
||||
@@ -25,18 +25,14 @@ let prettierPluginDocExplorerCache;
|
||||
let pluginsCache;
|
||||
|
||||
async function loadPrettier() {
|
||||
if (!prettierCache) {
|
||||
prettierCache = import(`./lib/${version}/prettier/standalone.mjs`);
|
||||
}
|
||||
prettierCache ??= import(`./lib/${version}/prettier/standalone.mjs`);
|
||||
return await prettierCache;
|
||||
}
|
||||
|
||||
async function loadPrettierPackageManifest() {
|
||||
if (!prettierPackageManifestCache) {
|
||||
prettierPackageManifestCache = import(
|
||||
`./lib/${version}/package-manifest.mjs`
|
||||
).then((m) => m.default);
|
||||
}
|
||||
prettierPackageManifestCache ??= import(
|
||||
`./lib/${version}/package-manifest.mjs`
|
||||
).then((m) => m.default);
|
||||
return await prettierPackageManifestCache;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user