Enable unicorn/no-useless-template-literals rule (#19383)
This commit is contained in:
1 parent
d1da0de0f6
commit
a42e063d5c
7 files changed
+25
-31
No files matched your search
+19
-24
@@ -43,8 +43,8 @@ vendors/**
|
|||||||
const configs = [
|
const configs = [
|
||||||
{ files: ["**/*.{js,mjs,cjs,jsx}"] },
|
{ files: ["**/*.{js,mjs,cjs,jsx}"] },
|
||||||
eslintPluginJs.configs.recommended,
|
eslintPluginJs.configs.recommended,
|
||||||
eslintPluginRegexp.configs["flat/recommended"],
|
eslintPluginRegexp.configs.recommended,
|
||||||
eslintPluginUnicorn.configs["flat/recommended"],
|
eslintPluginUnicorn.configs.recommended,
|
||||||
eslintConfigPrettier,
|
eslintConfigPrettier,
|
||||||
eslintConfigNodeStyleText,
|
eslintConfigNodeStyleText,
|
||||||
{
|
{
|
||||||
@@ -58,7 +58,6 @@ const configs = [
|
|||||||
"prettier-internal-rules": eslintPluginPrettierInternalRules,
|
"prettier-internal-rules": eslintPluginPrettierInternalRules,
|
||||||
"simple-import-sort": eslintPluginSimpleImportSort,
|
"simple-import-sort": eslintPluginSimpleImportSort,
|
||||||
},
|
},
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
"arrow-body-style": ["error", "as-needed"],
|
"arrow-body-style": ["error", "as-needed"],
|
||||||
curly: "error",
|
curly: "error",
|
||||||
@@ -250,26 +249,38 @@ const configs = [
|
|||||||
"unicorn/escape-case": "off",
|
"unicorn/escape-case": "off",
|
||||||
"unicorn/filename-case": ["error", { checkDirectories: false }],
|
"unicorn/filename-case": ["error", { checkDirectories: false }],
|
||||||
"unicorn/import-style": "off",
|
"unicorn/import-style": "off",
|
||||||
|
"unicorn/max-nested-calls": "off",
|
||||||
"unicorn/no-array-callback-reference": "off",
|
"unicorn/no-array-callback-reference": "off",
|
||||||
"unicorn/no-array-method-this-argument": "off",
|
"unicorn/no-array-method-this-argument": "off",
|
||||||
"unicorn/no-array-reduce": "off",
|
"unicorn/no-array-reduce": "off",
|
||||||
"unicorn/no-array-reverse": "off",
|
"unicorn/no-array-reverse": "off",
|
||||||
"unicorn/no-array-sort": "off",
|
"unicorn/no-array-sort": "off",
|
||||||
"unicorn/no-await-expression-member": "off",
|
"unicorn/no-await-expression-member": "off",
|
||||||
|
"unicorn/no-break-in-nested-loop": "off",
|
||||||
|
"unicorn/no-computed-property-existence-check": "off",
|
||||||
// Disabled due to false positives
|
// Disabled due to false positives
|
||||||
"unicorn/no-declarations-before-early-exit": "off",
|
"unicorn/no-declarations-before-early-exit": "off",
|
||||||
"unicorn/no-for-loop": "off",
|
"unicorn/no-for-loop": "off",
|
||||||
|
"unicorn/no-global-object-property-assignment": "off",
|
||||||
"unicorn/no-hex-escape": "off",
|
"unicorn/no-hex-escape": "off",
|
||||||
// Bug on `"\u{3000}"`
|
// Bug on `"\u{3000}"`
|
||||||
"unicorn/no-incorrect-template-string-interpolation": "off",
|
"unicorn/no-incorrect-template-string-interpolation": "off",
|
||||||
|
"unicorn/no-invalid-argument-count": "off",
|
||||||
"unicorn/no-negated-condition": "off",
|
"unicorn/no-negated-condition": "off",
|
||||||
"unicorn/no-nested-ternary": "off",
|
"unicorn/no-nested-ternary": "off",
|
||||||
"unicorn/no-null": "off",
|
"unicorn/no-null": "off",
|
||||||
"unicorn/no-process-exit": "off",
|
"unicorn/no-process-exit": "off",
|
||||||
"unicorn/no-thenable": "off",
|
"unicorn/no-thenable": "off",
|
||||||
"unicorn/no-this-outside-of-class": "off",
|
"unicorn/no-this-outside-of-class": "off",
|
||||||
|
"unicorn/no-top-level-side-effects": "off",
|
||||||
|
"unicorn/no-undeclared-class-members": "off",
|
||||||
"unicorn/no-unreadable-array-destructuring": "off",
|
"unicorn/no-unreadable-array-destructuring": "off",
|
||||||
|
"unicorn/no-unreadable-new-expression": "off",
|
||||||
|
"unicorn/no-unreadable-object-destructuring": "off",
|
||||||
"unicorn/no-unsafe-string-replacement": "off",
|
"unicorn/no-unsafe-string-replacement": "off",
|
||||||
|
"unicorn/no-useless-concat": "off",
|
||||||
|
"unicorn/no-useless-fallback-in-spread": "off",
|
||||||
|
"unicorn/no-useless-recursion": "off",
|
||||||
"unicorn/no-useless-switch-case": "off",
|
"unicorn/no-useless-switch-case": "off",
|
||||||
"unicorn/no-useless-undefined": [
|
"unicorn/no-useless-undefined": [
|
||||||
"error",
|
"error",
|
||||||
@@ -292,9 +303,11 @@ const configs = [
|
|||||||
getLastElementFunctions: ["getLast"],
|
getLastElementFunctions: ["getLast"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"unicorn/prefer-await": "off",
|
||||||
"unicorn/prefer-code-point": "off",
|
"unicorn/prefer-code-point": "off",
|
||||||
"unicorn/prefer-dom-node-append": "off",
|
"unicorn/prefer-dom-node-append": "off",
|
||||||
"unicorn/prefer-dom-node-remove": "off",
|
"unicorn/prefer-dom-node-remove": "off",
|
||||||
|
"unicorn/prefer-early-return": "off",
|
||||||
"unicorn/prefer-export-from": [
|
"unicorn/prefer-export-from": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
@@ -305,35 +318,17 @@ const configs = [
|
|||||||
"unicorn/prefer-global-this": "off",
|
"unicorn/prefer-global-this": "off",
|
||||||
"unicorn/prefer-https": "off",
|
"unicorn/prefer-https": "off",
|
||||||
"unicorn/prefer-includes-over-repeated-comparisons": "off",
|
"unicorn/prefer-includes-over-repeated-comparisons": "off",
|
||||||
|
"unicorn/prefer-minimal-ternary": "off",
|
||||||
"unicorn/prefer-query-selector": "off",
|
"unicorn/prefer-query-selector": "off",
|
||||||
|
"unicorn/prefer-short-arrow-method": "off",
|
||||||
"unicorn/prefer-ternary": "off",
|
"unicorn/prefer-ternary": "off",
|
||||||
|
"unicorn/prefer-unicode-code-point-escapes": "off",
|
||||||
"unicorn/prevent-abbreviations": "off",
|
"unicorn/prevent-abbreviations": "off",
|
||||||
"unicorn/relative-url-style": "off",
|
"unicorn/relative-url-style": "off",
|
||||||
"unicorn/require-array-sort-compare": "off",
|
"unicorn/require-array-sort-compare": "off",
|
||||||
"unicorn/switch-case-braces": ["error", "avoid"],
|
"unicorn/switch-case-braces": ["error", "avoid"],
|
||||||
"unicorn/template-indent": "error",
|
"unicorn/template-indent": "error",
|
||||||
|
|
||||||
// TODO: Enable the followings
|
|
||||||
"unicorn/prefer-short-arrow-method": "off",
|
|
||||||
"unicorn/no-useless-concat": "off",
|
|
||||||
"unicorn/no-computed-property-existence-check": "off",
|
|
||||||
"unicorn/no-useless-recursion": "off",
|
|
||||||
"unicorn/prefer-minimal-ternary": "off",
|
|
||||||
"unicorn/max-nested-calls": "off",
|
|
||||||
"unicorn/no-invalid-argument-count": "off",
|
|
||||||
"unicorn/no-unreadable-object-destructuring": "off",
|
|
||||||
"unicorn/no-unreadable-new-expression": "off",
|
|
||||||
"unicorn/prefer-unicode-code-point-escapes": "off",
|
|
||||||
"unicorn/no-break-in-nested-loop": "off",
|
|
||||||
"unicorn/prefer-early-return": "off",
|
|
||||||
"unicorn/no-undeclared-class-members": "off",
|
|
||||||
"unicorn/no-useless-fallback-in-spread": "off",
|
|
||||||
"unicorn/no-useless-template-literals": "off",
|
|
||||||
"unicorn/no-global-object-property-assignment": "off",
|
|
||||||
"unicorn/prefer-await": "off",
|
|
||||||
"unicorn/no-top-level-side-effects": "off",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
linterOptions: {
|
linterOptions: {
|
||||||
reportUnusedDisableDirectives: "error",
|
reportUnusedDisableDirectives: "error",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ async function buildFile({ packageConfig, file, cliOptions, results }) {
|
|||||||
prettyBytes(sizeDiff),
|
prettyBytes(sizeDiff),
|
||||||
);
|
);
|
||||||
|
|
||||||
sizeMessages.push(`${message}`);
|
sizeMessages.push(message);
|
||||||
} else {
|
} else {
|
||||||
sizeMessages.push(styleText.blue("[NEW FILE]"));
|
sizeMessages.push(styleText.blue("[NEW FILE]"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function getUmdWrapper({ name }, build) {
|
|||||||
for (let index = 0; index < path.length; index++) {
|
for (let index = 0; index < path.length; index++) {
|
||||||
const object = ["root", ...path.slice(0, index + 1)].join(".");
|
const object = ["root", ...path.slice(0, index + 1)].join(".");
|
||||||
if (index === path.length - 1) {
|
if (index === path.length - 1) {
|
||||||
globalObjectText.push(`${object}`);
|
globalObjectText.push(object);
|
||||||
} else {
|
} else {
|
||||||
globalObjectText.push(`${object} = ${object} || {};`);
|
globalObjectText.push(`${object} = ${object} || {};`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default async function showInstructionsAfterNpmPublish({
|
|||||||
next,
|
next,
|
||||||
}) {
|
}) {
|
||||||
if (next) {
|
if (next) {
|
||||||
console.log(`${styleText.green.bold`Prettier ${version} published!`}`);
|
console.log(styleText.green.bold`Prettier ${version} published!`);
|
||||||
await waitForEnter();
|
await waitForEnter();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,8 +121,7 @@ async function getOptionsForFile(context, filepath) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
context.logger.debug(
|
context.logger.debug(
|
||||||
`applied config-precedence (${context.argv.configPrecedence}): ` +
|
`applied config-precedence (${context.argv.configPrecedence}): ${JSON.stringify(appliedOptions)}`,
|
||||||
`${JSON.stringify(appliedOptions)}`,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hasPlugins) {
|
if (hasPlugins) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ describe("unit tests for getParserPluginByParserName", () => {
|
|||||||
{ falsyValue: undefined },
|
{ falsyValue: undefined },
|
||||||
{ falsyValue: false },
|
{ falsyValue: false },
|
||||||
])("throws an error when parserName is $falsyValue", ({ falsyValue }) => {
|
])("throws an error when parserName is $falsyValue", ({ falsyValue }) => {
|
||||||
const plugins = getMockPlugins(`${falsyValue}`);
|
const plugins = getMockPlugins(String(falsyValue));
|
||||||
expect(() => getParserPluginByParserName(plugins, falsyValue)).toThrow(
|
expect(() => getParserPluginByParserName(plugins, falsyValue)).toThrow(
|
||||||
"parserName is required.",
|
"parserName is required.",
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ describe("unit tests for getPrinterPluginByAstFormat", () => {
|
|||||||
{ falsyValue: undefined },
|
{ falsyValue: undefined },
|
||||||
{ falsyValue: false },
|
{ falsyValue: false },
|
||||||
])("throws an error when astFormat is $falsyValue", ({ falsyValue }) => {
|
])("throws an error when astFormat is $falsyValue", ({ falsyValue }) => {
|
||||||
const plugins = getMockPlugins(`${falsyValue}`);
|
const plugins = getMockPlugins(String(falsyValue));
|
||||||
expect(() => getPrinterPluginByAstFormat(plugins, falsyValue)).toThrow(
|
expect(() => getPrinterPluginByAstFormat(plugins, falsyValue)).toThrow(
|
||||||
"astFormat is required.",
|
"astFormat is required.",
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user