Fix quote style, enable quote rule (#7304)
This commit is contained in:
1 parent
0ffd9a774b
commit
beeaa98cb9
12 files changed
+25
-20
No files matched your search
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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}"`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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})?`,
|
||||
|
||||
@@ -838,7 +838,7 @@ function printOpeningTagStartMarker(node) {
|
||||
case "ieConditionalStartComment":
|
||||
return `<!--[if ${node.condition}`;
|
||||
case "ieConditionalEndComment":
|
||||
return `<!--<!`;
|
||||
return "<!--<!";
|
||||
case "interpolation":
|
||||
return "{{";
|
||||
case "docType":
|
||||
@@ -860,11 +860,11 @@ function printOpeningTagEndMarker(node) {
|
||||
return "]>";
|
||||
case "element":
|
||||
if (node.condition) {
|
||||
return `><!--<![endif]-->`;
|
||||
return "><!--<![endif]-->";
|
||||
}
|
||||
// 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":
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -12,7 +12,8 @@ describe("write cursorOffset to stderr with --cursor-offset <int>", () => {
|
||||
|
||||
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({
|
||||
/**
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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}\\""'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user