Skip to content

Commit

Permalink
Update npm packages, including Prettier 2.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Mar 22, 2020
1 parent 855185f commit 2a5b854
Show file tree
Hide file tree
Showing 18 changed files with 519 additions and 353 deletions.
26 changes: 13 additions & 13 deletions .eslintrc.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ module.exports = {
"plugin:flowtype/recommended",
"plugin:react/all",
"plugin:unicorn/recommended",
"plugin:vue/recommended"
"plugin:vue/recommended",
],
plugins: [
"prettier",
...pkg.files
.filter(name => !name.includes("/") && name !== "index.js")
.map(ruleFileName => ruleFileName.replace(/\.js$/, ""))
.filter((name) => !name.includes("/") && name !== "index.js")
.map((ruleFileName) => ruleFileName.replace(/\.js$/, "")),
],
parserOptions: {
parser: "babel-eslint",
Expand All @@ -23,12 +23,12 @@ module.exports = {
// Needed for the lint-verify-fail.test.js test.
loggerFn: () => {},
ecmaFeatures: {
jsx: true
}
jsx: true,
},
},
env: {
es6: true,
node: true
node: true,
},
rules: {
indent: "off",
Expand All @@ -51,7 +51,7 @@ module.exports = {
"unicorn/prevent-abbreviations": "off",
// Force a conflict with Prettier in test-lint/babel.js.
"object-curly-spacing": "off",
"babel/object-curly-spacing": ["error", "never"]
"babel/object-curly-spacing": ["error", "never"],
},
overrides: [
{
Expand All @@ -60,13 +60,13 @@ module.exports = {
rules: {
// Force a conflict with Prettier in test-lint/typescript.js.
// This is included in "plugin:@typescript-eslint/recommended".
"@typescript-eslint/indent": "error"
}
}
"@typescript-eslint/indent": "error",
},
},
],
settings: {
react: {
version: "16"
}
}
version: "16",
},
},
};
20 changes: 10 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module.exports = {
extends: [
"./.eslintrc.base.js",
...pkg.files
.filter(name => !name.includes("/"))
.map(ruleFileName => `./${ruleFileName}`)
.filter((name) => !name.includes("/"))
.map((ruleFileName) => `./${ruleFileName}`),
],
overrides: [
{
Expand All @@ -19,19 +19,19 @@ module.exports = {
{
selector: "SequenceExpression",
message:
"The comma operator is confusing and a common mistake. Don’t use it!"
}
"The comma operator is confusing and a common mistake. Don’t use it!",
},
],
quotes: [
"error",
"double",
{ avoidEscape: true, allowTemplateLiterals: false }
]
}
{ avoidEscape: true, allowTemplateLiterals: false },
],
},
},
{
files: ["*.test.js"],
env: { jest: true }
}
]
env: { jest: true },
},
],
};
4 changes: 2 additions & 2 deletions @typescript-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ module.exports = {
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/semi": "off",
"@typescript-eslint/space-before-function-paren": "off",
"@typescript-eslint/type-annotation-spacing": "off"
}
"@typescript-eslint/type-annotation-spacing": "off",
},
};
4 changes: 2 additions & 2 deletions babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module.exports = {
"babel/quotes": 0,

"babel/object-curly-spacing": "off",
"babel/semi": "off"
}
"babel/semi": "off",
},
};
42 changes: 21 additions & 21 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ if (module === require.main) {
"2: Conflicting rules found.",
"",
"For more information, see:",
"https://github.com/prettier/eslint-config-prettier#cli-helper-tool"
"https://github.com/prettier/eslint-config-prettier#cli-helper-tool",
].join("\n")
);
process.exit(1);
}

getStdin()
.then(string => {
.then((string) => {
const result = processString(string);
if (result.stderr) {
console.error(result.stderr);
Expand All @@ -44,7 +44,7 @@ if (module === require.main) {
}
process.exit(result.code);
})
.catch(error => {
.catch((error) => {
console.error("Unexpected error", error);
process.exit(1);
});
Expand All @@ -57,7 +57,7 @@ function processString(string) {
} catch (error) {
return {
stderr: `Failed to parse JSON:\n${error.message}`,
code: 1
code: 1,
};
}

Expand All @@ -69,7 +69,7 @@ function processString(string) {
) {
return {
stderr: `Expected a \`{"rules: {...}"}\` JSON object, but got:\n${string}`,
code: 1
code: 1,
};
}

Expand All @@ -80,8 +80,8 @@ function processString(string) {
Object.create(null),
...fs
.readdirSync(path.join(__dirname, ".."))
.filter(name => !name.startsWith(".") && name.endsWith(".js"))
.map(ruleFileName => require(`../${ruleFileName}`).rules)
.filter((name) => !name.startsWith(".") && name.endsWith(".js"))
.map((ruleFileName) => require(`../${ruleFileName}`).rules)
);

const regularRules = filterRules(
Expand All @@ -98,7 +98,7 @@ function processString(string) {
);

const flaggedRules = Object.keys(config.rules)
.map(ruleName => {
.map((ruleName) => {
const value = config.rules[ruleName];
const arrayValue = Array.isArray(value) ? value : [value];
const level = arrayValue[0];
Expand All @@ -110,7 +110,7 @@ function processString(string) {

const regularFlaggedRuleNames = filterRuleNames(
flaggedRules,
ruleName => ruleName in regularRules
(ruleName) => ruleName in regularRules
);
const optionsFlaggedRuleNames = filterRuleNames(
flaggedRules,
Expand All @@ -119,7 +119,7 @@ function processString(string) {
);
const specialFlaggedRuleNames = filterRuleNames(
flaggedRules,
ruleName => ruleName in specialRules
(ruleName) => ruleName in specialRules
);

if (
Expand All @@ -138,52 +138,52 @@ function processString(string) {
"However, the following rules are enabled but cannot be automatically checked. See:",
SPECIAL_RULES_URL,
"",
printRuleNames(specialFlaggedRuleNames)
printRuleNames(specialFlaggedRuleNames),
].join("\n");

return {
stdout: message,
code: 0
code: 0,
};
}

const regularMessage = [
"The following rules are unnecessary or might conflict with Prettier:",
"",
printRuleNames(regularFlaggedRuleNames)
printRuleNames(regularFlaggedRuleNames),
].join("\n");

const optionsMessage = [
"The following rules are enabled with options that might conflict with Prettier. See:",
SPECIAL_RULES_URL,
"",
printRuleNames(optionsFlaggedRuleNames)
printRuleNames(optionsFlaggedRuleNames),
].join("\n");

const specialMessage = [
"The following rules are enabled but cannot be automatically checked. See:",
SPECIAL_RULES_URL,
"",
printRuleNames(specialFlaggedRuleNames)
printRuleNames(specialFlaggedRuleNames),
].join("\n");

const message = [
regularFlaggedRuleNames.length === 0 ? null : regularMessage,
optionsFlaggedRuleNames.length === 0 ? null : optionsMessage,
specialFlaggedRuleNames.length === 0 ? null : specialMessage
specialFlaggedRuleNames.length === 0 ? null : specialMessage,
]
.filter(Boolean)
.join("\n\n");

return {
stdout: message,
code: 2
code: 2,
};
}

function filterRules(rules, fn) {
return Object.keys(rules)
.filter(ruleName => fn(ruleName, rules[ruleName]))
.filter((ruleName) => fn(ruleName, rules[ruleName]))
.reduce((obj, ruleName) => {
obj[ruleName] = true;
return obj;
Expand All @@ -192,15 +192,15 @@ function filterRules(rules, fn) {

function filterRuleNames(rules, fn) {
return rules
.filter(rule => fn(rule.ruleName, rule.options))
.map(rule => rule.ruleName);
.filter((rule) => fn(rule.ruleName, rule.options))
.map((rule) => rule.ruleName);
}

function printRuleNames(ruleNames) {
return ruleNames
.slice()
.sort()
.map(ruleName => `- ${ruleName}`)
.map((ruleName) => `- ${ruleName}`)
.join("\n");
}

Expand Down
2 changes: 1 addition & 1 deletion bin/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ module.exports = {
// Enable when Prettier supports SVG: https://github.com/prettier/prettier/issues/5322
// && firstOption.svg === "any"
);
}
},
};
4 changes: 2 additions & 2 deletions flowtype.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ module.exports = {
"flowtype/space-after-type-colon": "off",
"flowtype/space-before-generic-bracket": "off",
"flowtype/space-before-type-colon": "off",
"flowtype/union-intersection-spacing": "off"
}
"flowtype/union-intersection-spacing": "off",
},
};
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ module.exports = {
"unicode-bom": "off",
"wrap-iife": "off",
"wrap-regex": "off",
"yield-star-spacing": "off"
"yield-star-spacing": "off",
},
includeDeprecated && {
// Deprecated since version 4.0.0.
// https://github.com/eslint/eslint/pull/8286
"indent-legacy": "off",
// Deprecated since version 3.3.0.
// https://eslint.org/docs/rules/no-spaced-func
"no-spaced-func": "off"
"no-spaced-func": "off",
}
)
),
};
Loading

0 comments on commit 2a5b854

Please sign in to comment.