Update eslint-plugin-unicorn to v65 (#19303)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
1 parent
c81bb54b5f
commit
a5ba6d426e
18 files changed
+940
-944
No files matched your search
+10
-2
@@ -238,10 +238,14 @@ const configs = [
|
||||
"simple-import-sort/exports": "error",
|
||||
|
||||
/* eslint-plugin-unicorn */
|
||||
"unicorn/escape-case": "off",
|
||||
"unicorn/better-dom-traversing": "off",
|
||||
"unicorn/catch-error-name": "off",
|
||||
"unicorn/consistent-compound-words": "off",
|
||||
"unicorn/consistent-destructuring": "off",
|
||||
"unicorn/consistent-function-scoping": "off",
|
||||
"unicorn/consistent-json-file-read": ["error", "buffer"],
|
||||
"unicorn/escape-case": "off",
|
||||
"unicorn/filename-case": ["error", { checkDirectories: false }],
|
||||
"unicorn/import-style": "off",
|
||||
"unicorn/no-array-callback-reference": "off",
|
||||
"unicorn/no-array-method-this-argument": "off",
|
||||
@@ -256,6 +260,7 @@ const configs = [
|
||||
"unicorn/no-null": "off",
|
||||
"unicorn/no-process-exit": "off",
|
||||
"unicorn/no-thenable": "off",
|
||||
"unicorn/no-this-outside-of-class": "off",
|
||||
"unicorn/no-unreadable-array-destructuring": "off",
|
||||
"unicorn/no-useless-switch-case": "off",
|
||||
"unicorn/no-useless-undefined": [
|
||||
@@ -285,11 +290,14 @@ const configs = [
|
||||
"unicorn/prefer-export-from": [
|
||||
"error",
|
||||
{
|
||||
ignoreUsedVariables: true,
|
||||
checkUsedVariables: false,
|
||||
},
|
||||
],
|
||||
"unicorn/prefer-global-this": "off",
|
||||
"unicorn/prefer-https": "off",
|
||||
"unicorn/prefer-includes-over-repeated-comparisons": "off",
|
||||
"unicorn/prefer-query-selector": "off",
|
||||
"unicorn/prefer-string-repeat": "off",
|
||||
"unicorn/prefer-ternary": "off",
|
||||
"unicorn/prevent-abbreviations": "off",
|
||||
"unicorn/relative-url-style": "off",
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ const INSTALL_PACKAGE = Boolean(process.env.INSTALL_PACKAGE);
|
||||
const TEST_RUNTIME = process.env.TEST_RUNTIME ?? "nodejs";
|
||||
// When debugging production test, this flag can skip installing package
|
||||
const SKIP_PRODUCTION_INSTALL = Boolean(process.env.SKIP_PRODUCTION_INSTALL);
|
||||
const nodejsMajorVersion = Number(process.versions.node.split(".")[0]);
|
||||
const nodejsMajorVersion = Number(process.versions.node.split(".", 1)[0]);
|
||||
|
||||
let PRETTIER_DIR = isProduction
|
||||
? path.join(PROJECT_ROOT, "dist/prettier")
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@
|
||||
"eslint-plugin-n": "18.0.1",
|
||||
"eslint-plugin-regexp": "3.1.0",
|
||||
"eslint-plugin-simple-import-sort": "13.0.0",
|
||||
"eslint-plugin-unicorn": "64.0.0",
|
||||
"eslint-plugin-unicorn": "65.0.0",
|
||||
"esm-utils": "4.4.2",
|
||||
"get-port": "7.2.0",
|
||||
"gfm-test-suite": "0.0.2",
|
||||
|
||||
@@ -16,7 +16,7 @@ export function getReleaseUrl(version, previousVersion) {
|
||||
if (isPatch) {
|
||||
const urlToChangelog =
|
||||
`https://github.com/prettier/prettier/blob/${tag}/CHANGELOG.md#` +
|
||||
version.split(".").join("");
|
||||
version.replaceAll(".", "");
|
||||
body = `🔗 [Changelog](${urlToChangelog})`;
|
||||
} else {
|
||||
const blogPostInfo = getBlogPostInfo(version);
|
||||
|
||||
@@ -191,7 +191,7 @@ function print(path, options, print) {
|
||||
if (attrName) {
|
||||
// TODO: format style and srcset attributes
|
||||
if (attrName === "class") {
|
||||
const formattedClasses = text.trim().split(/\s+/).join(" ");
|
||||
const formattedClasses = text.trim().replaceAll(/\s+/g, " ");
|
||||
|
||||
let leadingSpace = false;
|
||||
let trailingSpace = false;
|
||||
@@ -437,7 +437,7 @@ function printStartingTag(path, print) {
|
||||
for (const attributeType of types) {
|
||||
path.each(({ node }) => {
|
||||
const index = attributes.indexOf(node);
|
||||
attributes.splice(index, 1, [line, print()]);
|
||||
attributes[index] = [line, print()];
|
||||
}, attributeType);
|
||||
}
|
||||
|
||||
@@ -707,9 +707,10 @@ function countTrailingNewLines(string) {
|
||||
}
|
||||
|
||||
function generateHardlines(number = 0) {
|
||||
return Array.from({
|
||||
length: Math.min(number, NEWLINES_TO_PRESERVE_MAX),
|
||||
}).fill(hardline);
|
||||
return Array.from(
|
||||
{ length: Math.min(number, NEWLINES_TO_PRESERVE_MAX) },
|
||||
() => hardline,
|
||||
);
|
||||
}
|
||||
|
||||
/* StringLiteral print helpers */
|
||||
|
||||
@@ -12,6 +12,6 @@ const isClassNames = ({ node }, options) =>
|
||||
|
||||
/** @type {AttributeValuePrint} */
|
||||
const printClassNames = (textToDoc, print, path /* , options*/) =>
|
||||
getUnescapedAttributeValue(path.node).trim().split(/\s+/).join(" ");
|
||||
getUnescapedAttributeValue(path.node).trim().replaceAll(/\s+/g, " ");
|
||||
|
||||
export { isClassNames, printClassNames };
|
||||
@@ -128,7 +128,7 @@ function lowerCaseIf(text, fn) {
|
||||
*/
|
||||
function restoreName(node) {
|
||||
const namespace = node.name.startsWith(":")
|
||||
? node.name.slice(1).split(":")[0]
|
||||
? node.name.slice(1).split(":", 1)[0]
|
||||
: null;
|
||||
const rawName = node.nameSpan.toString();
|
||||
const hasExplicitNamespace =
|
||||
|
||||
@@ -131,7 +131,7 @@ function printJestEachTemplateLiteral(path, options, print) {
|
||||
...tableBody.map((row) => row.cells.length),
|
||||
);
|
||||
|
||||
const maxColumnWidths = Array.from({ length: maxColumnCount }).fill(0);
|
||||
const maxColumnWidths = Array.from({ length: maxColumnCount }, () => 0);
|
||||
const table = [
|
||||
{ cells: headerNames },
|
||||
...tableBody.filter((row) => row.cells.length > 0),
|
||||
|
||||
@@ -359,20 +359,18 @@ function printTernary(path, options, print, args) {
|
||||
|
||||
":",
|
||||
|
||||
isAlternateTernary
|
||||
isAlternateTernary || !isBigTabs
|
||||
? " "
|
||||
: !isBigTabs
|
||||
? " "
|
||||
: shouldGroupTestAndConsequent
|
||||
? ifBreak(
|
||||
fillTab,
|
||||
ifBreak(
|
||||
isInChain || tryToParenthesizeAlternate ? " " : fillTab,
|
||||
" ",
|
||||
),
|
||||
{ groupId: testAndConsequentId },
|
||||
)
|
||||
: ifBreak(fillTab, " "),
|
||||
: shouldGroupTestAndConsequent
|
||||
? ifBreak(
|
||||
fillTab,
|
||||
ifBreak(
|
||||
isInChain || tryToParenthesizeAlternate ? " " : fillTab,
|
||||
" ",
|
||||
),
|
||||
{ groupId: testAndConsequentId },
|
||||
)
|
||||
: ifBreak(fillTab, " "),
|
||||
|
||||
isAlternateTernary
|
||||
? printedAlternateWithParens
|
||||
|
||||
@@ -14,7 +14,7 @@ import wikiLink from "./unified-plugins/wiki-link.js";
|
||||
* 1. restore unescaped character (Text)
|
||||
* 2. merge continuous Texts
|
||||
* 3. replace whitespaces in InlineCode#value with one whitespace
|
||||
* reference: http://spec.commonmark.org/0.25/#example-605
|
||||
* reference: https://spec.commonmark.org/0.25/#example-605
|
||||
* 4. split Text into Sentence
|
||||
*
|
||||
* interface Word { value: string }
|
||||
|
||||
@@ -89,6 +89,7 @@ function mergeChildren(ast, shouldMerge, mergeNode) {
|
||||
if (lastChild && shouldMerge(lastChild, child)) {
|
||||
child = mergeNode(lastChild, child);
|
||||
// Replace the previous node
|
||||
// eslint-disable-next-line unicorn/no-confusing-array-splice
|
||||
children.splice(-1, 1, child);
|
||||
changed ||= true;
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,21 +1,21 @@
|
||||
const urls = [
|
||||
"http://www.example.com:80/_a",
|
||||
"http://www.example.com:80/_a_",
|
||||
"http://www.example.com:80/_a__",
|
||||
"http://www.example.com:80/_a_b",
|
||||
"http://www.example.com:80/_a_/",
|
||||
"http://www.example.com:80/_a_/_",
|
||||
"http://www.example.com:80/*a",
|
||||
"http://www.example.com:80/*a*",
|
||||
"http://www.example.com:80/*a**",
|
||||
"http://www.example.com:80/*a*b",
|
||||
"http://www.example.com:80/*a*/",
|
||||
"http://www.example.com:80/*a*/*",
|
||||
"http://www.example.com:80/_a*",
|
||||
"http://www.example.com:80/_a_*",
|
||||
"http://www.example.com:80/_a*b",
|
||||
"http://www.example.com:80/_a*/",
|
||||
"http://www.example.com:80/_a_/*",
|
||||
"https://www.example.com:80/_a",
|
||||
"https://www.example.com:80/_a_",
|
||||
"https://www.example.com:80/_a__",
|
||||
"https://www.example.com:80/_a_b",
|
||||
"https://www.example.com:80/_a_/",
|
||||
"https://www.example.com:80/_a_/_",
|
||||
"https://www.example.com:80/*a",
|
||||
"https://www.example.com:80/*a*",
|
||||
"https://www.example.com:80/*a**",
|
||||
"https://www.example.com:80/*a*b",
|
||||
"https://www.example.com:80/*a*/",
|
||||
"https://www.example.com:80/*a*/*",
|
||||
"https://www.example.com:80/_a*",
|
||||
"https://www.example.com:80/_a_*",
|
||||
"https://www.example.com:80/_a*b",
|
||||
"https://www.example.com:80/_a*/",
|
||||
"https://www.example.com:80/_a_/*",
|
||||
];
|
||||
|
||||
const wrappers = [
|
||||
|
||||
@@ -4,7 +4,7 @@ import jestPathSerializer from "../path-serializer.js";
|
||||
expect.addSnapshotSerializer(jestPathSerializer);
|
||||
|
||||
const NODE_TS_SUPPORT_FLAGS = ["--experimental-strip-types"];
|
||||
const NODE_JS_MAJOR_VERSION = Number(process.versions.node.split(".")[0]);
|
||||
const NODE_JS_MAJOR_VERSION = Number(process.versions.node.split(".", 1)[0]);
|
||||
|
||||
const getOutputTabWidth = (code) =>
|
||||
code.match(/\n(?<indention>\s+)return/).groups.indention.length;
|
||||
|
||||
@@ -25,7 +25,7 @@ const IS_CI = Boolean(process.env.CI);
|
||||
const removeFinalNewLine = (string) =>
|
||||
string.endsWith("\n") ? string.slice(0, -1) : string;
|
||||
const SUPPORTS_DISABLE_WARNING_FLAG =
|
||||
Number(process.versions.node.split(".")[0]) >= 20;
|
||||
Number(process.versions.node.split(".", 1)[0]) >= 20;
|
||||
const promiseWithResolvers = Promise.withResolvers
|
||||
? Promise.withResolvers.bind(Promise)
|
||||
: () => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import llmsTxtPlugin from "./plugins/llms-txt-plugin.mjs";
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const packageJsonFile = new URL("../package.json", import.meta.url);
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile, "utf8"));
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile));
|
||||
const GITHUB_URL = `https://github.com/${packageJson.repository}`;
|
||||
|
||||
/**
|
||||
@@ -210,7 +210,7 @@ const config = {
|
||||
},
|
||||
{
|
||||
label: "Stack Overflow",
|
||||
href: "http://stackoverflow.com/questions/tagged/prettier",
|
||||
href: "https://stackoverflow.com/questions/tagged/prettier",
|
||||
},
|
||||
{
|
||||
label: "@PrettierCode on X",
|
||||
|
||||
@@ -104,7 +104,7 @@ export default function getCodeSamples(parser) {
|
||||
"}",
|
||||
].join("\n");
|
||||
case "less":
|
||||
// Copied from http://lesscss.org/features/#detached-rulesets-feature
|
||||
// Copied from https://lesscss.org/features/#detached-rulesets-feature
|
||||
return [
|
||||
"@my-ruleset: {",
|
||||
" .my-selector {",
|
||||
@@ -173,7 +173,7 @@ export default function getCodeSamples(parser) {
|
||||
"+ and [another one]",
|
||||
"",
|
||||
"",
|
||||
" [another one]: http://example.com 'Example title'",
|
||||
" [another one]: https://example.com 'Example title'",
|
||||
"",
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
|
||||
"Curabitur consectetur maximus risus, sed maximus tellus tincidunt et.",
|
||||
@@ -240,7 +240,7 @@ export default function getCodeSamples(parser) {
|
||||
"</style>",
|
||||
].join("\n");
|
||||
case "yaml":
|
||||
// modified from http://yaml.org/start.html
|
||||
// modified from https://yaml.org/spec/1.2.2/#25-full-length-example
|
||||
return [
|
||||
"---",
|
||||
"invoice : 34843",
|
||||
@@ -283,7 +283,7 @@ export default function getCodeSamples(parser) {
|
||||
"",
|
||||
].join("\n");
|
||||
case "glimmer":
|
||||
// modified from http://handlebarsjs.com/
|
||||
// modified from https://handlebarsjs.com/
|
||||
return [
|
||||
' <div class="entry" >',
|
||||
" <h1>{{ title }}</h1>",
|
||||
|
||||
@@ -3634,15 +3634,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"clean-regexp@npm:^1.0.0":
|
||||
version: 1.0.0
|
||||
resolution: "clean-regexp@npm:1.0.0"
|
||||
dependencies:
|
||||
escape-string-regexp: "npm:^1.0.5"
|
||||
checksum: 10/0b1ce281b07da2463c6882ea2e8409119b6cabbd9f687cdbdcee942c45b2b9049a2084f7b5f228c63ef9f21e722963ae0bfe56a735dbdbdd92512867625a7e40
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"cliui@npm:^8.0.1":
|
||||
version: 8.0.1
|
||||
resolution: "cliui@npm:8.0.1"
|
||||
@@ -4063,6 +4054,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"detect-indent@npm:^7.0.2":
|
||||
version: 7.0.2
|
||||
resolution: "detect-indent@npm:7.0.2"
|
||||
checksum: 10/ef215d1b55a14f677ce03e840973b25362b6f8cd3f566bc82831fa1abb2be6a95423729bc573dc2334b1371ad7be18d9ec67e1a9611b71a04cb6d63f0d8e54cc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"detect-newline@npm:^3.1.0":
|
||||
version: 3.1.0
|
||||
resolution: "detect-newline@npm:3.1.0"
|
||||
@@ -4488,29 +4486,28 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"eslint-plugin-unicorn@npm:64.0.0":
|
||||
version: 64.0.0
|
||||
resolution: "eslint-plugin-unicorn@npm:64.0.0"
|
||||
"eslint-plugin-unicorn@npm:65.0.0":
|
||||
version: 65.0.0
|
||||
resolution: "eslint-plugin-unicorn@npm:65.0.0"
|
||||
dependencies:
|
||||
"@babel/helper-validator-identifier": "npm:^7.28.5"
|
||||
"@eslint-community/eslint-utils": "npm:^4.9.1"
|
||||
change-case: "npm:^5.4.4"
|
||||
ci-info: "npm:^4.4.0"
|
||||
clean-regexp: "npm:^1.0.0"
|
||||
core-js-compat: "npm:^3.49.0"
|
||||
detect-indent: "npm:^7.0.2"
|
||||
find-up-simple: "npm:^1.0.1"
|
||||
globals: "npm:^17.4.0"
|
||||
indent-string: "npm:^5.0.0"
|
||||
is-builtin-module: "npm:^5.0.0"
|
||||
jsesc: "npm:^3.1.0"
|
||||
pluralize: "npm:^8.0.0"
|
||||
regexp-tree: "npm:^0.1.27"
|
||||
regjsparser: "npm:^0.13.0"
|
||||
semver: "npm:^7.7.4"
|
||||
strip-indent: "npm:^4.1.1"
|
||||
peerDependencies:
|
||||
eslint: ">=9.38.0"
|
||||
checksum: 10/3211dadefe8ec43526372a302e48503da42f5e1d3b45d8e20bc29e30dd142b442d70d22ea8617a4ca5494b184b36656d0e81c1e299d12a8e991ac1a86ed35e42
|
||||
checksum: 10/1c303889522994b50b48d16ebe8f2df0cfddb0d4fe366681c9519f1cc9d875bf86f67266837777e7f3bcebbb3cb9e68e610d7ba718218ff59071fcad55f02c43
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -8127,7 +8124,7 @@ __metadata:
|
||||
eslint-plugin-n: "npm:18.0.1"
|
||||
eslint-plugin-regexp: "npm:3.1.0"
|
||||
eslint-plugin-simple-import-sort: "npm:13.0.0"
|
||||
eslint-plugin-unicorn: "npm:64.0.0"
|
||||
eslint-plugin-unicorn: "npm:65.0.0"
|
||||
esm-utils: "npm:4.4.2"
|
||||
espree: "npm:11.2.0"
|
||||
fast-glob: "npm:3.3.3"
|
||||
@@ -8388,15 +8385,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"regexp-tree@npm:^0.1.27":
|
||||
version: 0.1.27
|
||||
resolution: "regexp-tree@npm:0.1.27"
|
||||
bin:
|
||||
regexp-tree: bin/regexp-tree
|
||||
checksum: 10/08c70c8adb5a0d4af1061bf9eb05d3b6e1d948c433d6b7008e4b5eb12a49429c2d6ca8e9106339a432aa0d07bd6e1bccc638d8f4ab0d045f3adad22182b300a2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"regexp-util@npm:2.0.3, regexp-util@npm:^2.0.3":
|
||||
version: 2.0.3
|
||||
resolution: "regexp-util@npm:2.0.3"
|
||||
|
||||
Reference in new issue
Block a user