diff --git a/.eslintrc.yml b/.eslintrc.yml index 52280121c..793e5802e 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -23,6 +23,10 @@ rules: - never prefer-arrow-callback: error prefer-const: error + quotes: + - error + - double + - avoidEscape: true react/display-name: off react/no-deprecated: off react/prop-types: off diff --git a/scripts/build/rollup-plugins/evaluate.js b/scripts/build/rollup-plugins/evaluate.js index be5b00c32..46042e1a5 100644 --- a/scripts/build/rollup-plugins/evaluate.js +++ b/scripts/build/rollup-plugins/evaluate.js @@ -13,7 +13,7 @@ module.exports = function() { require(id.replace(/^\0commonjs-proxy:/, "")), (_, v) => { if (typeof v === "function") { - throw new Error(`Cannot evaluate functions.`); + throw new Error("Cannot evaluate functions."); } return v; } diff --git a/scripts/release/steps/validate-new-version.js b/scripts/release/steps/validate-new-version.js index 3f529c0be..6f049575d 100644 --- a/scripts/release/steps/validate-new-version.js +++ b/scripts/release/steps/validate-new-version.js @@ -5,7 +5,7 @@ const semver = require("semver"); module.exports = async function({ version, previousVersion }) { if (!semver.valid(version)) { - throw Error(`Invalid version specified`); + throw Error("Invalid version specified"); } if (!semver.gt(version, previousVersion)) { diff --git a/src/config/resolve-config.js b/src/config/resolve-config.js index 0c27eed05..6f14d7ab8 100644 --- a/src/config/resolve-config.js +++ b/src/config/resolve-config.js @@ -23,7 +23,7 @@ const getExplorerMemoized = mem(opts => { if (typeof result.config !== "object") { throw new Error( - `Config is only allowed to be an object, ` + + "Config is only allowed to be an object, " + `but received ${typeof result.config} in "${result.filepath}"` ); } diff --git a/src/language-css/printer-postcss.js b/src/language-css/printer-postcss.js index da73429f6..b070c15ac 100644 --- a/src/language-css/printer-postcss.js +++ b/src/language-css/printer-postcss.js @@ -914,7 +914,7 @@ const STANDARD_UNIT_REGEX = /[a-zA-Z]+/g; const WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g; const ADJUST_NUMBERS_REGEX = RegExp( STRING_REGEX.source + - `|` + + "|" + `(${WORD_PART_REGEX.source})?` + `(${NUMBER_REGEX.source})` + `(${STANDARD_UNIT_REGEX.source})?`, diff --git a/src/language-html/printer-html.js b/src/language-html/printer-html.js index ebf2ce56b..5afd14d67 100644 --- a/src/language-html/printer-html.js +++ b/src/language-html/printer-html.js @@ -838,7 +838,7 @@ function printOpeningTagStartMarker(node) { case "ieConditionalStartComment": return ``; + return ">"; } // fall through default: - return `>`; + return ">"; } } @@ -893,9 +893,9 @@ function printClosingTagEndMarker(node, options) { switch (node.type) { case "ieConditionalComment": case "ieConditionalEndComment": - return `[endif]-->`; + return "[endif]-->"; case "ieConditionalStartComment": - return `]>`; + return "]>"; case "interpolation": return "}}"; case "element": diff --git a/src/language-html/syntax-attribute.js b/src/language-html/syntax-attribute.js index 46419cab9..751a71aa1 100644 --- a/src/language-html/syntax-attribute.js +++ b/src/language-html/syntax-attribute.js @@ -19,7 +19,7 @@ function printImgSrcset(value) { const hasX = srcset.some(src => src.d); if (hasW + hasH + hasX !== 1) { - throw new Error(`Mixed descriptor in srcset is not supported`); + throw new Error("Mixed descriptor in srcset is not supported"); } const key = hasW ? "w" : hasH ? "h" : "d"; diff --git a/tests_integration/__tests__/cursor-offset.js b/tests_integration/__tests__/cursor-offset.js index 58a04cdd6..f5faeed82 100644 --- a/tests_integration/__tests__/cursor-offset.js +++ b/tests_integration/__tests__/cursor-offset.js @@ -12,7 +12,8 @@ describe("write cursorOffset to stderr with --cursor-offset ", () => { describe("cursorOffset should not be affected by full-width character", () => { runPrettier("cli", ["--cursor-offset", "21", "--parser", "babel"], { - input: `const x = ["中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文"];` + input: + 'const x = ["中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文"];' // ^ offset = 21 ^ width = 80 }).test({ /** diff --git a/tests_integration/__tests__/early-exit.js b/tests_integration/__tests__/early-exit.js index 2148eaa74..9111cfafa 100644 --- a/tests_integration/__tests__/early-exit.js +++ b/tests_integration/__tests__/early-exit.js @@ -16,24 +16,24 @@ describe("show usage with --help", () => { }); }); -describe(`show detailed usage with --help l (alias)`, () => { +describe("show detailed usage with --help l (alias)", () => { runPrettier("cli", ["--help", "l"]).test({ status: 0 }); }); -describe(`show detailed usage with plugin options (automatic resolution)`, () => { +describe("show detailed usage with plugin options (automatic resolution)", () => { runPrettier("plugins/automatic", [ "--help", "tab-width", "--parser=bar", - `--plugin-search-dir=.` + "--plugin-search-dir=." ]).test({ status: 0 }); }); -describe(`show detailed usage with plugin options (manual resolution)`, () => { +describe("show detailed usage with plugin options (manual resolution)", () => { runPrettier("cli", [ "--help", "tab-width", diff --git a/tests_integration/__tests__/file-info.js b/tests_integration/__tests__/file-info.js index 9150d48a3..af327817c 100644 --- a/tests_integration/__tests__/file-info.js +++ b/tests_integration/__tests__/file-info.js @@ -333,17 +333,17 @@ describe("API getFileInfo.sync with ignorePath", () => { test("with relative filePath", () => { expect( prettier.getFileInfo.sync(filePath, options).ignored - ).toMatchInlineSnapshot(`true`); + ).toMatchInlineSnapshot("true"); }); test("with relative filePath starts with dot", () => { expect( prettier.getFileInfo.sync(`./${filePath}`, options).ignored - ).toMatchInlineSnapshot(`true`); + ).toMatchInlineSnapshot("true"); }); test("with absolute filePath", () => { expect( prettier.getFileInfo.sync(path.resolve(filePath), options).ignored - ).toMatchInlineSnapshot(`true`); + ).toMatchInlineSnapshot("true"); }); }); diff --git a/tests_integration/__tests__/format.js b/tests_integration/__tests__/format.js index 9221de2f1..8303cd487 100644 --- a/tests_integration/__tests__/format.js +++ b/tests_integration/__tests__/format.js @@ -50,7 +50,7 @@ test("should work with foo plugin instance", () => { prettier.format(input, { parser: "foo-parser", plugins: [fooPlugin] }) ) ).toMatchInlineSnapshot( - `"\\"{\\\\\\"tabWidth\\\\\\":8,\\\\\\"bracketSpacing\\\\\\":false}\\""` + '"\\"{\\\\\\"tabWidth\\\\\\":8,\\\\\\"bracketSpacing\\\\\\":false}\\""' ); }); diff --git a/tests_integration/runPrettier.js b/tests_integration/runPrettier.js index 5632ad8fd..00198e673 100644 --- a/tests_integration/runPrettier.js +++ b/tests_integration/runPrettier.js @@ -63,7 +63,7 @@ function runPrettier(dir, args, options) { const origStatSync = fs.statSync; jest.spyOn(fs, "statSync").mockImplementation(filename => { - if (path.basename(filename) === `virtualDirectory`) { + if (path.basename(filename) === "virtualDirectory") { return origStatSync(path.join(__dirname, __filename)); } return origStatSync(filename);