tools: update ESLint to 5.14.0

Update ESLint to 5.14.0

PR-URL: https://github.com/nodejs/node/pull/26142
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
This commit is contained in:
cjihrig 2019-02-15 16:51:43 -05:00
parent 2da7ff5e96
commit 77b39c2eb2
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
184 changed files with 3212 additions and 3652 deletions

224
tools/node_modules/eslint/README.md generated vendored
View File

@ -197,170 +197,82 @@ These folks keep the project moving and are resources for help.
The people who manage releases, review feature requests, and meet regularly to ensure ESLint is properly maintained. The people who manage releases, review feature requests, and meet regularly to ensure ESLint is properly maintained.
<table> <!-- NOTE: This section is autogenerated. Do not manually edit.-->
<tbody> <!--tscstart-->
<tr> <table><tbody><tr><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/nzakas">
<a href="https://github.com/nzakas"> <img src="https://github.com/nzakas.png?s=75" width="75" height="75"><br />
<img src="https://github.com/nzakas.png?s=75" width="75px" height="75px"><br/> Nicholas C. Zakas
<sub>Nicholas C. Zakas</sub></a> </a>
</td> </td><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/platinumazure">
<a href="https://github.com/ilyavolodin"> <img src="https://github.com/platinumazure.png?s=75" width="75" height="75"><br />
<img src="https://github.com/ilyavolodin.png?s=75" width="75px" height="75px"><br/> Kevin Partington
<sub>Ilya Volodin</sub></a> </a>
</td> </td><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/ilyavolodin">
<a href="https://github.com/btmills"> <img src="https://github.com/ilyavolodin.png?s=75" width="75" height="75"><br />
<img src="https://github.com/btmills.png?s=75" width="75px" height="75px"><br/> Ilya Volodin
<sub>Brandon Mills</sub></a> </a>
</td> </td><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/btmills">
<a href="https://github.com/gyandeeps"> <img src="https://github.com/btmills.png?s=75" width="75" height="75"><br />
<img src="https://github.com/gyandeeps.png?s=75" width="75px" height="75px"><br/> Brandon Mills
<sub>Gyandeep Singh</sub></a> </a>
</td> </td><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/mysticatea">
<a href="https://github.com/mysticatea"> <img src="https://github.com/mysticatea.png?s=75" width="75" height="75"><br />
<img src="https://github.com/mysticatea.png?s=75" width="75px" height="75px"><br/> Toru Nagashima
<sub>Toru Nagashima</sub></a> </a>
</td> </td><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/gyandeeps">
<a href="https://github.com/alberto"> <img src="https://github.com/gyandeeps.png?s=75" width="75" height="75"><br />
<img src="https://github.com/alberto.png?s=75" width="75px" height="75px"><br/> Gyandeep Singh
<sub>Alberto Rodríguez</sub></a> </a>
</td> </td><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/kaicataldo">
<a href="https://github.com/kaicataldo"> <img src="https://github.com/kaicataldo.png?s=75" width="75" height="75"><br />
<img src="https://github.com/kaicataldo.png?s=75" width="75px" height="75px"><br/> Kai Cataldo
<sub>Kai Cataldo</sub></a> </a>
</td> </td><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/not-an-aardvark">
<a href="https://github.com/not-an-aardvark"> <img src="https://github.com/not-an-aardvark.png?s=75" width="75" height="75"><br />
<img src="https://github.com/not-an-aardvark.png?s=75" width="75px" height="75px"><br/> Teddy Katz
<sub>Teddy Katz</sub></a> </a>
</td> </td></tr></tbody></table><!--tscend-->
<td align="center" valign="top" width="11%">
<a href="https://github.com/platinumazure">
<img src="https://github.com/platinumazure.png?s=75" width="75px" height="75px"><br/>
<sub>Kevin Partington</sub></a>
</td>
</tr>
</tbody>
</table>
### Committers ### Committers
The people who review and fix bugs and help triage issues. The people who review and fix bugs and help triage issues.
<table> <!-- NOTE: This section is autogenerated. Do not manually edit.-->
<tbody> <!--committersstart-->
<tr> <table><tbody><tr><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/aladdin-add">
<a href="https://github.com/Aladdin-ADD"> <img src="https://github.com/aladdin-add.png?s=75" width="75" height="75"><br />
<img src="https://github.com/Aladdin-ADD.png?s=75" width="75px" height="75px"><br/> 薛定谔的猫
<sub>薛定谔的猫</sub></a> </a>
</td> </td><td align="center" valign="top" width="11%">
<td align="center" valign="top" width="11%"> <a href="https://github.com/g-plane">
<a href="https://github.com/g-plane"> <img src="https://github.com/g-plane.png?s=75" width="75" height="75"><br />
<img src="https://github.com/g-plane.png?s=75" width="75px" height="75px"><br/> Pig Fang
<sub>Pig Fang</sub></a> </a>
</td> </td></tr></tbody></table><!--committersend-->
</tr>
</tbody>
</table>
### Alumni
Former TSC members and committers who previously helped maintain ESLint.
<table>
<tbody>
<tr>
<td align="center" valign="top" width="11%">
<a href="https://github.com/lo1tuma">
<img src="https://github.com/lo1tuma.png?s=75" width="75px" height="75px"><br/>
<sub>Mathias Schreck</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/xjamundx">
<img src="https://github.com/xjamundx.png?s=75" width="75px" height="75px"><br/>
<sub>Jamund Ferguson</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/ianvs">
<img src="https://github.com/ianvs.png?s=75" width="75px" height="75px"><br/>
<sub>Ian VanSchooten</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/byk">
<img src="https://github.com/byk.png?s=75" width="75px" height="75px"><br/>
<sub>Burak Yiğit Kaya</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/michaelficarra">
<img src="https://github.com/michaelficarra.png?s=75" width="75px" height="75px"><br/>
<sub>Michael Ficarra</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/pedrottimark">
<img src="https://github.com/pedrottimark.png?s=75" width="75px" height="75px"><br/>
<sub>Mark Pedrotti</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/markelog">
<img src="https://github.com/markelog.png?s=75" width="75px" height="75px"><br/>
<sub>Oleg Gaidarenko</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/mikesherov">
<img src="https://github.com/mikesherov.png?s=75" width="75px" height="75px"><br/>
<sub>Mike Sherov</sub></a>
</td>
</tr>
<tr>
<td align="center" valign="top" width="11%">
<a href="https://github.com/hzoo">
<img src="https://github.com/hzoo.png?s=75" width="75px" height="75px"><br/>
<sub>Henry Zhu</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/mdevils">
<img src="https://github.com/mdevils.png?s=75" width="75px" height="75px"><br/>
<sub>Marat Dulin</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/zxqfox">
<img src="https://github.com/zxqfox.png?s=75" width="75px" height="75px"><br/>
<sub>Alexej Yaroshevich</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/vitorbal">
<img src="https://github.com/vitorbal.png?s=75" width="75px" height="75px"><br/>
<sub>Vitor Balocco</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/JamesHenry">
<img src="https://github.com/JamesHenry.png?s=75" width="75px" height="75px"><br/>
<sub>James Henry</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/soda0289">
<img src="https://github.com/soda0289.png?s=75" width="75px" height="75px"><br/>
<sub>Reyad Attiyat</sub></a>
</td>
<td align="center" valign="top" width="11%">
<a href="https://github.com/VictorHom">
<img src="https://github.com/VictorHom.png?s=75" width="75px" height="75px"><br/>
<sub>Victor Hom</sub></a>
</td>
</tr>
</tbody>
</table>
## Sponsors ## Sponsors
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://opencollective.com/eslint) to get your logo on our README and website.
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
<!--sponsorsstart-->
<h3>Gold Sponsors</h3>
<p><a href="https://code.facebook.com/projects/"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Fres.cloudinary.com%2Fopencollective%2Fimage%2Fupload%2Fv1508519428%2FS9gk78AS_400x400_fulq2l.jpg&height=96" alt="Facebook Open Source" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F098e3bd0-4d57-11e8-9324-0f6cc1f92bf1.png&height=96" alt="Airbnb" height="96"></a></p><h3>Silver Sponsors</h3>
<p><a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F68ed8b70-ebf2-11e6-9958-cb7e79408c56.png&height=96" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3>
<p><a href="http://faithlife.com/ref/about"><img src="https://images.opencollective.com/proxy/images/?src=https%3A%2F%2Flogo.clearbit.com%2Ffaithlife.com&height=96" alt="Faithlife" height="32"></a></p>
<!--sponsorsend-->
## Technology Sponsors
* Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com) * Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com)

View File

@ -455,6 +455,9 @@ class CLIEngine {
if (this.options.rules && Object.keys(this.options.rules).length) { if (this.options.rules && Object.keys(this.options.rules).length) {
const loadedRules = this.linter.getRules(); const loadedRules = this.linter.getRules();
// Ajv validator with default schema will mutate original object, so we must clone it recursively.
this.options.rules = lodash.cloneDeep(this.options.rules);
Object.keys(this.options.rules).forEach(name => { Object.keys(this.options.rules).forEach(name => {
validator.validateRuleOptions(loadedRules.get(name), name, this.options.rules[name], "CLI"); validator.validateRuleOptions(loadedRules.get(name), name, this.options.rules[name], "CLI");
}); });

View File

@ -280,15 +280,38 @@ function writeYAMLConfigFile(config, filePath) {
* Writes a configuration file in JavaScript format. * Writes a configuration file in JavaScript format.
* @param {Object} config The configuration object to write. * @param {Object} config The configuration object to write.
* @param {string} filePath The filename to write to. * @param {string} filePath The filename to write to.
* @throws {Error} If an error occurs linting the config file contents.
* @returns {void} * @returns {void}
* @private * @private
*/ */
function writeJSConfigFile(config, filePath) { function writeJSConfigFile(config, filePath) {
debug(`Writing JS config file: ${filePath}`); debug(`Writing JS config file: ${filePath}`);
const content = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`; let contentToWrite;
const stringifiedContent = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`;
fs.writeFileSync(filePath, content, "utf8"); try {
const CLIEngine = require("../cli-engine");
const linter = new CLIEngine({
baseConfig: config,
fix: true,
useEslintrc: false
});
const report = linter.executeOnText(stringifiedContent);
contentToWrite = report.results[0].output || stringifiedContent;
} catch (e) {
debug("Error linting JavaScript config file, writing unlinted version");
const errorMessage = e.message;
contentToWrite = stringifiedContent;
e.message = "An error occurred while generating your JavaScript config file. ";
e.message += "A config file was still generated, but the config file itself may not follow your linting rules.";
e.message += `\nError: ${errorMessage}`;
throw e;
} finally {
fs.writeFileSync(filePath, contentToWrite, "utf8");
}
} }
/** /**

View File

@ -3,6 +3,7 @@
* @author Ilya Volodin * @author Ilya Volodin
*/ */
"use strict"; "use strict";
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -28,6 +29,8 @@ const debug = require("debug")("eslint:config-initializer");
// Private // Private
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
const DEFAULT_ECMA_VERSION = 2018;
/* istanbul ignore next: hard to test fs function */ /* istanbul ignore next: hard to test fs function */
/** /**
* Create .eslintrc file in the current working directory * Create .eslintrc file in the current working directory
@ -239,43 +242,65 @@ function configureRules(answers, config) {
* @returns {Object} config object * @returns {Object} config object
*/ */
function processAnswers(answers) { function processAnswers(answers) {
let config = { rules: {}, env: {}, parserOptions: {} }; let config = {
rules: {},
env: {},
parserOptions: {},
extends: []
};
config.parserOptions.ecmaVersion = answers.ecmaVersion; // set the latest ECMAScript version
if (answers.ecmaVersion >= 2015) { config.parserOptions.ecmaVersion = DEFAULT_ECMA_VERSION;
if (answers.modules) { config.env.es6 = true;
config.parserOptions.sourceType = "module"; config.globals = {
} Atomics: "readonly",
config.env.es6 = true; SharedArrayBuffer: "readonly"
} };
if (answers.commonjs) { // set the module type
if (answers.moduleType === "esm") {
config.parserOptions.sourceType = "module";
} else if (answers.moduleType === "commonjs") {
config.env.commonjs = true; config.env.commonjs = true;
} }
// add in browser and node environments if necessary
answers.env.forEach(env => { answers.env.forEach(env => {
config.env[env] = true; config.env[env] = true;
}); });
if (answers.jsx) {
config.parserOptions = config.parserOptions || {}; // add in library information
config.parserOptions.ecmaFeatures = config.parserOptions.ecmaFeatures || {}; if (answers.framework === "react") {
config.parserOptions.ecmaFeatures.jsx = true; config.parserOptions.ecmaFeatures = {
if (answers.react) { jsx: true
config.plugins = ["react"]; };
config.parserOptions.ecmaVersion = 2018; config.plugins = ["react"];
} else if (answers.framework === "vue") {
config.plugins = ["vue"];
config.extends.push("plugin:vue/essential");
}
// setup rules based on problems/style enforcement preferences
if (answers.purpose === "problems") {
config.extends.unshift("eslint:recommended");
} else if (answers.purpose === "style") {
if (answers.source === "prompt") {
config.extends.unshift("eslint:recommended");
config.rules.indent = ["error", answers.indent];
config.rules.quotes = ["error", answers.quotes];
config.rules["linebreak-style"] = ["error", answers.linebreak];
config.rules.semi = ["error", answers.semi ? "always" : "never"];
} else if (answers.source === "auto") {
config = configureRules(answers, config);
config = autoconfig.extendFromRecommended(config);
} }
} }
if (answers.source === "prompt") { // normalize extends
config.extends = "eslint:recommended"; if (config.extends.length === 0) {
config.rules.indent = ["error", answers.indent]; delete config.extends;
config.rules.quotes = ["error", answers.quotes]; } else if (config.extends.length === 1) {
config.rules["linebreak-style"] = ["error", answers.linebreak]; config.extends = config.extends[0];
config.rules.semi = ["error", answers.semi ? "always" : "never"];
}
if (answers.source === "auto") {
config = configureRules(answers, config);
config = autoconfig.extendFromRecommended(config);
} }
ConfigOps.normalizeToStrings(config); ConfigOps.normalizeToStrings(config);
@ -324,7 +349,7 @@ function getLocalESLintVersion() {
* @returns {string} The shareable config name. * @returns {string} The shareable config name.
*/ */
function getStyleGuideName(answers) { function getStyleGuideName(answers) {
if (answers.styleguide === "airbnb" && !answers.airbnbReact) { if (answers.styleguide === "airbnb" && answers.framework !== "react") {
return "airbnb-base"; return "airbnb-base";
} }
return answers.styleguide; return answers.styleguide;
@ -417,16 +442,62 @@ function askInstallModules(modules, packageJsonExists) {
function promptUser() { function promptUser() {
return inquirer.prompt([ return inquirer.prompt([
{
type: "list",
name: "purpose",
message: "How would you like to use ESLint?",
default: "problems",
choices: [
{ name: "To check syntax only", value: "syntax" },
{ name: "To check syntax and find problems", value: "problems" },
{ name: "To check syntax, find problems, and enforce code style", value: "style" }
]
},
{
type: "list",
name: "moduleType",
message: "What type of modules does your project use?",
default: "esm",
choices: [
{ name: "JavaScript modules (import/export)", value: "esm" },
{ name: "CommonJS (require/exports)", value: "commonjs" },
{ name: "None of these", value: "none" }
]
},
{
type: "list",
name: "framework",
message: "Which framework does your project use?",
default: "react",
choices: [
{ name: "React", value: "react" },
{ name: "Vue.js", value: "vue" },
{ name: "None of these", value: "none" }
]
},
{
type: "checkbox",
name: "env",
message: "Where does your code run?",
default: ["browser"],
choices: [
{ name: "Browser", value: "browser" },
{ name: "Node", value: "node" }
]
},
{ {
type: "list", type: "list",
name: "source", name: "source",
message: "How would you like to configure ESLint?", message: "How would you like to define a style for your project?",
default: "prompt", default: "guide",
choices: [ choices: [
{ name: "Use a popular style guide", value: "guide" }, { name: "Use a popular style guide", value: "guide" },
{ name: "Answer questions about your style", value: "prompt" }, { name: "Answer questions about your style", value: "prompt" },
{ name: "Inspect your JavaScript file(s)", value: "auto" } { name: "Inspect your JavaScript file(s)", value: "auto" }
] ],
when(answers) {
return answers.purpose === "style";
}
}, },
{ {
type: "list", type: "list",
@ -442,15 +513,6 @@ function promptUser() {
return answers.source === "guide" && answers.packageJsonExists; return answers.source === "guide" && answers.packageJsonExists;
} }
}, },
{
type: "confirm",
name: "airbnbReact",
message: "Do you use React?",
default: false,
when(answers) {
return answers.styleguide === "airbnb";
}
},
{ {
type: "input", type: "input",
name: "patterns", name: "patterns",
@ -470,10 +532,7 @@ function promptUser() {
name: "format", name: "format",
message: "What format do you want your config file to be in?", message: "What format do you want your config file to be in?",
default: "JavaScript", default: "JavaScript",
choices: ["JavaScript", "YAML", "JSON"], choices: ["JavaScript", "YAML", "JSON"]
when(answers) {
return ((answers.source === "guide" && answers.packageJsonExists) || answers.source === "auto");
}
}, },
{ {
type: "confirm", type: "confirm",
@ -492,6 +551,15 @@ function promptUser() {
} }
]).then(earlyAnswers => { ]).then(earlyAnswers => {
// early exit if no style guide is necessary
if (earlyAnswers.purpose !== "style") {
const config = processAnswers(earlyAnswers);
const modules = getModulesList(config);
return askInstallModules(modules, earlyAnswers.packageJsonExists)
.then(() => writeFile(config, earlyAnswers.format));
}
// early exit if you are using a style guide // early exit if you are using a style guide
if (earlyAnswers.source === "guide") { if (earlyAnswers.source === "guide") {
if (!earlyAnswers.packageJsonExists) { if (!earlyAnswers.packageJsonExists) {
@ -501,130 +569,69 @@ function promptUser() {
if (earlyAnswers.installESLint === false && !semver.satisfies(earlyAnswers.localESLintVersion, earlyAnswers.requiredESLintVersionRange)) { if (earlyAnswers.installESLint === false && !semver.satisfies(earlyAnswers.localESLintVersion, earlyAnswers.requiredESLintVersionRange)) {
log.info(`Note: it might not work since ESLint's version is mismatched with the ${earlyAnswers.styleguide} config.`); log.info(`Note: it might not work since ESLint's version is mismatched with the ${earlyAnswers.styleguide} config.`);
} }
if (earlyAnswers.styleguide === "airbnb" && !earlyAnswers.airbnbReact) { if (earlyAnswers.styleguide === "airbnb" && earlyAnswers.framework !== "react") {
earlyAnswers.styleguide = "airbnb-base"; earlyAnswers.styleguide = "airbnb-base";
} }
const config = getConfigForStyleGuide(earlyAnswers.styleguide); const config = ConfigOps.merge(processAnswers(earlyAnswers), getConfigForStyleGuide(earlyAnswers.styleguide));
const modules = getModulesList(config); const modules = getModulesList(config);
return askInstallModules(modules, earlyAnswers.packageJsonExists) return askInstallModules(modules, earlyAnswers.packageJsonExists)
.then(() => writeFile(config, earlyAnswers.format)); .then(() => writeFile(config, earlyAnswers.format));
} }
// continue with the questions otherwise... if (earlyAnswers.source === "auto") {
const combinedAnswers = Object.assign({}, earlyAnswers);
const config = processAnswers(combinedAnswers);
const modules = getModulesList(config);
return askInstallModules(modules).then(() => writeFile(config, earlyAnswers.format));
}
// continue with the style questions otherwise...
return inquirer.prompt([ return inquirer.prompt([
{ {
type: "list", type: "list",
name: "ecmaVersion", name: "indent",
message: "Which version of ECMAScript do you use?", message: "What style of indentation do you use?",
choices: [ default: "tab",
{ name: "ES3", value: 3 }, choices: [{ name: "Tabs", value: "tab" }, { name: "Spaces", value: 4 }]
{ name: "ES5", value: 5 }, },
{ name: "ES2015", value: 2015 }, {
{ name: "ES2016", value: 2016 }, type: "list",
{ name: "ES2017", value: 2017 }, name: "quotes",
{ name: "ES2018", value: 2018 } message: "What quotes do you use for strings?",
], default: "double",
default: 1 // This is the index in the choices list choices: [{ name: "Double", value: "double" }, { name: "Single", value: "single" }]
},
{
type: "list",
name: "linebreak",
message: "What line endings do you use?",
default: "unix",
choices: [{ name: "Unix", value: "unix" }, { name: "Windows", value: "windows" }]
}, },
{ {
type: "confirm", type: "confirm",
name: "modules", name: "semi",
message: "Are you using ES6 modules?", message: "Do you require semicolons?",
default: false, default: true
when(answers) {
return answers.ecmaVersion >= 2015;
}
}, },
{ {
type: "checkbox", type: "list",
name: "env", name: "format",
message: "Where will your code run?", message: "What format do you want your config file to be in?",
default: ["browser"], default: "JavaScript",
choices: [{ name: "Browser", value: "browser" }, { name: "Node", value: "node" }] choices: ["JavaScript", "YAML", "JSON"]
},
{
type: "confirm",
name: "commonjs",
message: "Do you use CommonJS?",
default: false,
when(answers) {
return answers.env.some(env => env === "browser");
}
},
{
type: "confirm",
name: "jsx",
message: "Do you use JSX?",
default: false
},
{
type: "confirm",
name: "react",
message: "Do you use React?",
default: false,
when(answers) {
return answers.jsx;
}
} }
]).then(secondAnswers => { ]).then(answers => {
const totalAnswers = Object.assign({}, earlyAnswers, answers);
// early exit if you are using automatic style generation const config = processAnswers(totalAnswers);
if (earlyAnswers.source === "auto") { const modules = getModulesList(config);
const combinedAnswers = Object.assign({}, earlyAnswers, secondAnswers);
const config = processAnswers(combinedAnswers); return askInstallModules(modules).then(() => writeFile(config, answers.format));
const modules = getModulesList(config);
return askInstallModules(modules).then(() => writeFile(config, earlyAnswers.format));
}
// continue with the style questions otherwise...
return inquirer.prompt([
{
type: "list",
name: "indent",
message: "What style of indentation do you use?",
default: "tab",
choices: [{ name: "Tabs", value: "tab" }, { name: "Spaces", value: 4 }]
},
{
type: "list",
name: "quotes",
message: "What quotes do you use for strings?",
default: "double",
choices: [{ name: "Double", value: "double" }, { name: "Single", value: "single" }]
},
{
type: "list",
name: "linebreak",
message: "What line endings do you use?",
default: "unix",
choices: [{ name: "Unix", value: "unix" }, { name: "Windows", value: "windows" }]
},
{
type: "confirm",
name: "semi",
message: "Do you require semicolons?",
default: true
},
{
type: "list",
name: "format",
message: "What format do you want your config file to be in?",
default: "JavaScript",
choices: ["JavaScript", "YAML", "JSON"]
}
]).then(answers => {
const totalAnswers = Object.assign({}, earlyAnswers, secondAnswers, answers);
const config = processAnswers(totalAnswers);
const modules = getModulesList(config);
return askInstallModules(modules).then(() => writeFile(config, answers.format));
});
}); });
}); });
} }

View File

@ -386,12 +386,14 @@ module.exports = {
case true: case true:
case "true": case "true":
case "writeable": case "writeable":
case "writable":
return "writeable"; return "writeable";
case null: case null:
case false: case false:
case "false": case "false":
case "readable": case "readable":
case "readonly":
return "readable"; return "readable";
// Fallback to minimize compatibility impact // Fallback to minimize compatibility impact

View File

@ -85,10 +85,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
getWithoutSet: { getWithoutSet: {
type: "boolean" type: "boolean",
default: false
}, },
setWithoutGet: { setWithoutGet: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -34,11 +34,13 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
multiline: { multiline: {
type: "boolean" type: "boolean",
default: true
}, },
minItems: { minItems: {
type: ["integer", "null"], type: ["integer", "null"],
minimum: 0 minimum: 0,
default: null
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -155,7 +155,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowImplicit: { allowImplicit: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -34,11 +34,13 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
multiline: { multiline: {
type: "boolean" type: "boolean",
default: false
}, },
minItems: { minItems: {
type: ["integer", "null"], type: ["integer", "null"],
minimum: 0 minimum: 0,
default: null
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -46,7 +46,7 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
requireReturnForObjectLiteral: { type: "boolean" } requireReturnForObjectLiteral: { type: "boolean", default: false }
}, },
additionalProperties: false additionalProperties: false
} }

View File

@ -35,7 +35,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
requireForBlockBody: { requireForBlockBody: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -32,10 +32,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
before: { before: {
type: "boolean" type: "boolean",
default: true
}, },
after: { after: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -54,11 +56,10 @@ module.exports = {
create(context) { create(context) {
// merge rules with default // merge rules with default
const rule = { before: true, after: true }, const rule = Object.assign({}, context.options[0]);
option = context.options[0] || {};
rule.before = option.before !== false; rule.before = rule.before !== false;
rule.after = option.after !== false; rule.after = rule.after !== false;
const sourceCode = context.getSourceCode(); const sourceCode = context.getSourceCode();

View File

@ -30,7 +30,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowSingleLine: { allowSingleLine: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -25,7 +25,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
ignoreDestructuring: { ignoreDestructuring: {
type: "boolean" type: "boolean",
default: false
}, },
properties: { properties: {
enum: ["always", "never"] enum: ["always", "never"]
@ -54,7 +55,7 @@ module.exports = {
const options = context.options[0] || {}; const options = context.options[0] || {};
let properties = options.properties || ""; let properties = options.properties || "";
const ignoreDestructuring = options.ignoreDestructuring || false; const ignoreDestructuring = options.ignoreDestructuring;
const allow = options.allow || []; const allow = options.allow || [];
if (properties !== "always" && properties !== "never") { if (properties !== "always" && properties !== "never") {

View File

@ -17,12 +17,7 @@ const astUtils = require("../util/ast-utils");
const DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN, const DEFAULT_IGNORE_PATTERN = astUtils.COMMENTS_IGNORE_PATTERN,
WHITESPACE = /\s/g, WHITESPACE = /\s/g,
MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/, // TODO: Combine w/ max-len pattern? MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/; // TODO: Combine w/ max-len pattern?
DEFAULTS = {
ignorePattern: null,
ignoreInlineComments: false,
ignoreConsecutiveComments: false
};
/* /*
* Base schema body for defining the basic capitalization rule, ignorePattern, * Base schema body for defining the basic capitalization rule, ignorePattern,
@ -33,17 +28,27 @@ const SCHEMA_BODY = {
type: "object", type: "object",
properties: { properties: {
ignorePattern: { ignorePattern: {
type: "string" type: "string",
default: ""
}, },
ignoreInlineComments: { ignoreInlineComments: {
type: "boolean" type: "boolean",
default: false
}, },
ignoreConsecutiveComments: { ignoreConsecutiveComments: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
}; };
const DEFAULTS = Object.keys(SCHEMA_BODY.properties).reduce(
(obj, current) => {
obj[current] = SCHEMA_BODY.properties[current].default;
return obj;
},
{}
);
/** /**
* Get normalized options for either block or line comments from the given * Get normalized options for either block or line comments from the given
@ -59,11 +64,7 @@ const SCHEMA_BODY = {
* @param {string} which Either "line" or "block". * @param {string} which Either "line" or "block".
* @returns {Object} The normalized options. * @returns {Object} The normalized options.
*/ */
function getNormalizedOptions(rawOptions, which) { function getNormalizedOptions(rawOptions = {}, which) {
if (!rawOptions) {
return Object.assign({}, DEFAULTS);
}
return Object.assign({}, DEFAULTS, rawOptions[which] || rawOptions); return Object.assign({}, DEFAULTS, rawOptions[which] || rawOptions);
} }

View File

@ -38,7 +38,7 @@ module.exports = {
} }
}, },
create(context) { create(context) {
const config = context.options[0] ? Object.assign({}, context.options[0]) : {}; const config = Object.assign({}, context.options[0]);
const exceptMethods = new Set(config.exceptMethods || []); const exceptMethods = new Set(config.exceptMethods || []);
const stack = []; const stack = [];

View File

@ -28,10 +28,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
before: { before: {
type: "boolean" type: "boolean",
default: false
}, },
after: { after: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -50,8 +52,8 @@ module.exports = {
const tokensAndComments = sourceCode.tokensAndComments; const tokensAndComments = sourceCode.tokensAndComments;
const options = { const options = {
before: context.options[0] ? !!context.options[0].before : false, before: context.options[0] ? context.options[0].before : false,
after: context.options[0] ? !!context.options[0].after : true after: context.options[0] ? context.options[0].after : true
}; };
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -118,6 +120,10 @@ module.exports = {
report(reportItem, "before", tokens.left); report(reportItem, "before", tokens.left);
} }
if (tokens.right && astUtils.isClosingParenToken(tokens.right)) {
return;
}
if (tokens.right && !options.after && tokens.right.type === "Line") { if (tokens.right && !options.after && tokens.right.type === "Line") {
return; return;
} }

View File

@ -41,11 +41,13 @@ module.exports = {
properties: { properties: {
maximum: { maximum: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 20
}, },
max: { max: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 20
} }
}, },
additionalProperties: false additionalProperties: false
@ -63,13 +65,9 @@ module.exports = {
const option = context.options[0]; const option = context.options[0];
let THRESHOLD = 20; let THRESHOLD = 20;
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { if (typeof option === "object") {
THRESHOLD = option.maximum; THRESHOLD = option.maximum || option.max;
} } else if (typeof option === "number") {
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
THRESHOLD = option.max;
}
if (typeof option === "number") {
THRESHOLD = option; THRESHOLD = option;
} }

View File

@ -66,7 +66,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
treatUndefinedAsUnspecified: { treatUndefinedAsUnspecified: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -33,10 +33,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowKeywords: { allowKeywords: {
type: "boolean" type: "boolean",
default: true
}, },
allowPattern: { allowPattern: {
type: "string" type: "string",
default: ""
} }
}, },
additionalProperties: false additionalProperties: false
@ -53,7 +55,7 @@ module.exports = {
create(context) { create(context) {
const options = context.options[0] || {}; const options = context.options[0] || {};
const allowKeywords = options.allowKeywords === void 0 || !!options.allowKeywords; const allowKeywords = options.allowKeywords === void 0 || options.allowKeywords;
const sourceCode = context.getSourceCode(); const sourceCode = context.getSourceCode();
let allowPattern; let allowPattern;

View File

@ -38,7 +38,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
null: { null: {
enum: ["always", "never", "ignore"] enum: ["always", "never", "ignore"],
default: "always"
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -50,7 +50,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowNewlines: { allowNewlines: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -27,7 +27,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowArrowFunctions: { allowArrowFunctions: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -43,7 +44,7 @@ module.exports = {
create(context) { create(context) {
const style = context.options[0], const style = context.options[0],
allowArrowFunctions = context.options[1] && context.options[1].allowArrowFunctions === true, allowArrowFunctions = context.options[1] && context.options[1].allowArrowFunctions,
enforceDeclarations = (style === "declaration"), enforceDeclarations = (style === "declaration"),
stack = []; stack = [];

View File

@ -60,7 +60,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowImplicit: { allowImplicit: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -26,10 +26,11 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
min: { min: {
type: "number" type: "integer",
default: 2
}, },
max: { max: {
type: "number" type: "integer"
}, },
exceptions: { exceptions: {
type: "array", type: "array",

View File

@ -28,13 +28,16 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
properties: { properties: {
type: "boolean" type: "boolean",
default: false
}, },
onlyDeclarations: { onlyDeclarations: {
type: "boolean" type: "boolean",
default: false
}, },
ignoreDestructuring: { ignoreDestructuring: {
type: "boolean" type: "boolean",
default: false
} }
} }
} }

View File

@ -518,7 +518,8 @@ module.exports = {
properties: { properties: {
SwitchCase: { SwitchCase: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 0
}, },
VariableDeclarator: { VariableDeclarator: {
oneOf: [ oneOf: [
@ -582,7 +583,8 @@ module.exports = {
ObjectExpression: ELEMENT_LIST_SCHEMA, ObjectExpression: ELEMENT_LIST_SCHEMA,
ImportDeclaration: ELEMENT_LIST_SCHEMA, ImportDeclaration: ELEMENT_LIST_SCHEMA,
flatTernaryExpressions: { flatTernaryExpressions: {
type: "boolean" type: "boolean",
default: false
}, },
ignoredNodes: { ignoredNodes: {
type: "array", type: "array",
@ -594,7 +596,8 @@ module.exports = {
} }
}, },
ignoreComments: { ignoreComments: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -650,7 +653,7 @@ module.exports = {
} }
if (context.options[1]) { if (context.options[1]) {
lodash.merge(options, context.options[1]); Object.assign(options, context.options[1]);
if (typeof options.VariableDeclarator === "number" || options.VariableDeclarator === "first") { if (typeof options.VariableDeclarator === "number" || options.VariableDeclarator === "first") {
options.VariableDeclarator = { options.VariableDeclarator = {

View File

@ -75,7 +75,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
ignoreForLoopInit: { ignoreForLoopInit: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -148,16 +148,20 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
mode: { mode: {
enum: ["strict", "minimum"] enum: ["strict", "minimum"],
default: "strict"
}, },
on: { on: {
enum: ["colon", "value"] enum: ["colon", "value"],
default: "colon"
}, },
beforeColon: { beforeColon: {
type: "boolean" type: "boolean",
default: false
}, },
afterColon: { afterColon: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -165,13 +169,16 @@ module.exports = {
] ]
}, },
mode: { mode: {
enum: ["strict", "minimum"] enum: ["strict", "minimum"],
default: "strict"
}, },
beforeColon: { beforeColon: {
type: "boolean" type: "boolean",
default: false
}, },
afterColon: { afterColon: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -183,13 +190,16 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
mode: { mode: {
enum: ["strict", "minimum"] enum: ["strict", "minimum"],
default: "strict"
}, },
beforeColon: { beforeColon: {
type: "boolean" type: "boolean",
default: false
}, },
afterColon: { afterColon: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -206,16 +216,20 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
mode: { mode: {
enum: ["strict", "minimum"] enum: ["strict", "minimum"],
default: "strict"
}, },
on: { on: {
enum: ["colon", "value"] enum: ["colon", "value"],
default: "colon"
}, },
beforeColon: { beforeColon: {
type: "boolean" type: "boolean",
default: false
}, },
afterColon: { afterColon: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -223,13 +237,16 @@ module.exports = {
] ]
}, },
mode: { mode: {
enum: ["strict", "minimum"] enum: ["strict", "minimum"],
default: "strict"
}, },
beforeColon: { beforeColon: {
type: "boolean" type: "boolean",
default: false
}, },
afterColon: { afterColon: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -244,13 +261,16 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
mode: { mode: {
enum: ["strict", "minimum"] enum: ["strict", "minimum"],
default: "strict"
}, },
beforeColon: { beforeColon: {
type: "boolean" type: "boolean",
default: false
}, },
afterColon: { afterColon: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -259,13 +279,16 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
mode: { mode: {
enum: ["strict", "minimum"] enum: ["strict", "minimum"],
default: "strict"
}, },
beforeColon: { beforeColon: {
type: "boolean" type: "boolean",
default: false
}, },
afterColon: { afterColon: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -274,16 +297,20 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
mode: { mode: {
enum: ["strict", "minimum"] enum: ["strict", "minimum"],
default: "strict"
}, },
on: { on: {
enum: ["colon", "value"] enum: ["colon", "value"],
default: "colon"
}, },
beforeColon: { beforeColon: {
type: "boolean" type: "boolean",
default: false
}, },
afterColon: { afterColon: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -80,16 +80,16 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
before: { type: "boolean" }, before: { type: "boolean", default: true },
after: { type: "boolean" }, after: { type: "boolean", default: true },
overrides: { overrides: {
type: "object", type: "object",
properties: KEYS.reduce((retv, key) => { properties: KEYS.reduce((retv, key) => {
retv[key] = { retv[key] = {
type: "object", type: "object",
properties: { properties: {
before: { type: "boolean" }, before: { type: "boolean", default: true },
after: { type: "boolean" } after: { type: "boolean", default: true }
}, },
additionalProperties: false additionalProperties: false
}; };
@ -228,9 +228,9 @@ module.exports = {
* Keys are keywords (there are for every keyword). * Keys are keywords (there are for every keyword).
* Values are instances of `{"before": function, "after": function}`. * Values are instances of `{"before": function, "after": function}`.
*/ */
function parseOptions(options) { function parseOptions(options = {}) {
const before = !options || options.before !== false; const before = options.before !== false;
const after = !options || options.after !== false; const after = options.after !== false;
const defaultValue = { const defaultValue = {
before: before ? expectSpaceBefore : unexpectSpaceBefore, before: before ? expectSpaceBefore : unexpectSpaceBefore,
after: after ? expectSpaceAfter : unexpectSpaceAfter after: after ? expectSpaceAfter : unexpectSpaceAfter

View File

@ -31,16 +31,19 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
position: { position: {
enum: ["above", "beside"] enum: ["above", "beside"],
default: "above"
}, },
ignorePattern: { ignorePattern: {
type: "string" type: "string"
}, },
applyDefaultPatterns: { applyDefaultPatterns: {
type: "boolean" type: "boolean",
default: true
}, },
applyDefaultIgnorePatterns: { applyDefaultIgnorePatterns: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -69,9 +72,9 @@ module.exports = {
ignorePattern = options.ignorePattern; ignorePattern = options.ignorePattern;
if (Object.prototype.hasOwnProperty.call(options, "applyDefaultIgnorePatterns")) { if (Object.prototype.hasOwnProperty.call(options, "applyDefaultIgnorePatterns")) {
applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false; applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns;
} else { } else {
applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false; applyDefaultIgnorePatterns = options.applyDefaultPatterns;
} }
} }

View File

@ -68,22 +68,28 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
beforeBlockComment: { beforeBlockComment: {
type: "boolean" type: "boolean",
default: true
}, },
afterBlockComment: { afterBlockComment: {
type: "boolean" type: "boolean",
default: false
}, },
beforeLineComment: { beforeLineComment: {
type: "boolean" type: "boolean",
default: false
}, },
afterLineComment: { afterLineComment: {
type: "boolean" type: "boolean",
default: false
}, },
allowBlockStart: { allowBlockStart: {
type: "boolean" type: "boolean",
default: false
}, },
allowBlockEnd: { allowBlockEnd: {
type: "boolean" type: "boolean",
default: false
}, },
allowClassStart: { allowClassStart: {
type: "boolean" type: "boolean"
@ -121,19 +127,13 @@ module.exports = {
create(context) { create(context) {
const options = context.options[0] ? Object.assign({}, context.options[0]) : {}; const options = Object.assign({}, context.options[0]);
const ignorePattern = options.ignorePattern; const ignorePattern = options.ignorePattern;
const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN; const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN;
const customIgnoreRegExp = new RegExp(ignorePattern); const customIgnoreRegExp = new RegExp(ignorePattern);
const applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false; const applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false;
options.beforeLineComment = options.beforeLineComment || false;
options.afterLineComment = options.afterLineComment || false;
options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true; options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true;
options.afterBlockComment = options.afterBlockComment || false;
options.allowBlockStart = options.allowBlockStart || false;
options.allowBlockEnd = options.allowBlockEnd || false;
const sourceCode = context.getSourceCode(); const sourceCode = context.getSourceCode();

View File

@ -31,7 +31,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
exceptAfterSingleLine: { exceptAfterSingleLine: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -32,11 +32,13 @@ module.exports = {
properties: { properties: {
maximum: { maximum: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 4
}, },
max: { max: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 4
} }
}, },
additionalProperties: false additionalProperties: false
@ -59,11 +61,8 @@ module.exports = {
option = context.options[0]; option = context.options[0];
let maxDepth = 4; let maxDepth = 4;
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { if (typeof option === "object") {
maxDepth = option.maximum; maxDepth = option.maximum || option.max;
}
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
maxDepth = option.max;
} }
if (typeof option === "number") { if (typeof option === "number") {
maxDepth = option; maxDepth = option;

View File

@ -14,7 +14,8 @@ const OPTIONS_SCHEMA = {
properties: { properties: {
code: { code: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 80
}, },
comments: { comments: {
type: "integer", type: "integer",
@ -22,28 +23,35 @@ const OPTIONS_SCHEMA = {
}, },
tabWidth: { tabWidth: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 4
}, },
ignorePattern: { ignorePattern: {
type: "string" type: "string"
}, },
ignoreComments: { ignoreComments: {
type: "boolean" type: "boolean",
default: false
}, },
ignoreStrings: { ignoreStrings: {
type: "boolean" type: "boolean",
default: false
}, },
ignoreUrls: { ignoreUrls: {
type: "boolean" type: "boolean",
default: false
}, },
ignoreTemplateLiterals: { ignoreTemplateLiterals: {
type: "boolean" type: "boolean",
default: false
}, },
ignoreRegExpLiterals: { ignoreRegExpLiterals: {
type: "boolean" type: "boolean",
default: false
}, },
ignoreTrailingComments: { ignoreTrailingComments: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -121,8 +129,7 @@ module.exports = {
} }
// The options object must be the last option specified… // The options object must be the last option specified…
const lastOption = context.options[context.options.length - 1]; const options = Object.assign({}, context.options[context.options.length - 1]);
const options = typeof lastOption === "object" ? Object.create(lastOption) : {};
// …but max code length… // …but max code length…
if (typeof context.options[0] === "number") { if (typeof context.options[0] === "number") {

View File

@ -19,16 +19,20 @@ const OPTIONS_SCHEMA = {
properties: { properties: {
max: { max: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 50
}, },
skipComments: { skipComments: {
type: "boolean" type: "boolean",
default: false
}, },
skipBlankLines: { skipBlankLines: {
type: "boolean" type: "boolean",
default: false
}, },
IIFEs: { IIFEs: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -97,18 +101,10 @@ module.exports = {
let IIFEs = false; let IIFEs = false;
if (typeof option === "object") { if (typeof option === "object") {
if (typeof option.max === "number") { maxLines = option.max;
maxLines = option.max; skipComments = option.skipComments;
} skipBlankLines = option.skipBlankLines;
if (typeof option.skipComments === "boolean") { IIFEs = option.IIFEs;
skipComments = option.skipComments;
}
if (typeof option.skipBlankLines === "boolean") {
skipBlankLines = option.skipBlankLines;
}
if (typeof option.IIFEs === "boolean") {
IIFEs = option.IIFEs;
}
} else if (typeof option === "number") { } else if (typeof option === "number") {
maxLines = option; maxLines = option;
} }

View File

@ -38,13 +38,16 @@ module.exports = {
properties: { properties: {
max: { max: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 300
}, },
skipComments: { skipComments: {
type: "boolean" type: "boolean",
default: false
}, },
skipBlankLines: { skipBlankLines: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -61,11 +64,9 @@ module.exports = {
const option = context.options[0]; const option = context.options[0];
let max = 300; let max = 300;
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") { if (typeof option === "object") {
max = option.max; max = option.max;
} } else if (typeof option === "number") {
if (typeof option === "number") {
max = option; max = option;
} }
@ -86,7 +87,7 @@ module.exports = {
/** /**
* Returns the line numbers of a comment that don't have any code on the same line * Returns the line numbers of a comment that don't have any code on the same line
* @param {Node} comment The comment node to check * @param {Node} comment The comment node to check
* @returns {int[]} The line numbers * @returns {number[]} The line numbers
*/ */
function getLinesWithoutCode(comment) { function getLinesWithoutCode(comment) {
let start = comment.loc.start.line; let start = comment.loc.start.line;

View File

@ -32,11 +32,13 @@ module.exports = {
properties: { properties: {
maximum: { maximum: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 10
}, },
max: { max: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 10
} }
}, },
additionalProperties: false additionalProperties: false
@ -57,13 +59,9 @@ module.exports = {
const option = context.options[0]; const option = context.options[0];
let THRESHOLD = 10; let THRESHOLD = 10;
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { if (typeof option === "object") {
THRESHOLD = option.maximum; THRESHOLD = option.maximum || option.max;
} } else if (typeof option === "number") {
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
THRESHOLD = option.max;
}
if (typeof option === "number") {
THRESHOLD = option; THRESHOLD = option;
} }

View File

@ -40,11 +40,13 @@ module.exports = {
properties: { properties: {
maximum: { maximum: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 3
}, },
max: { max: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 3
} }
}, },
additionalProperties: false additionalProperties: false
@ -62,11 +64,8 @@ module.exports = {
const option = context.options[0]; const option = context.options[0];
let numParams = 3; let numParams = 3;
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { if (typeof option === "object") {
numParams = option.maximum; numParams = option.maximum || option.max;
}
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
numParams = option.max;
} }
if (typeof option === "number") { if (typeof option === "number") {
numParams = option; numParams = option;

View File

@ -31,7 +31,8 @@ module.exports = {
properties: { properties: {
max: { max: {
type: "integer", type: "integer",
minimum: 1 minimum: 1,
default: 1
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -40,11 +40,13 @@ module.exports = {
properties: { properties: {
maximum: { maximum: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 10
}, },
max: { max: {
type: "integer", type: "integer",
minimum: 0 minimum: 0,
default: 10
} }
}, },
additionalProperties: false additionalProperties: false
@ -78,13 +80,9 @@ module.exports = {
topLevelFunctions = []; topLevelFunctions = [];
let maxStatements = 10; let maxStatements = 10;
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") { if (typeof option === "object") {
maxStatements = option.maximum; maxStatements = option.maximum || option.max;
} } else if (typeof option === "number") {
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
maxStatements = option.max;
}
if (typeof option === "number") {
maxStatements = option; maxStatements = option;
} }

View File

@ -88,10 +88,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
newIsCap: { newIsCap: {
type: "boolean" type: "boolean",
default: true
}, },
capIsNew: { capIsNew: {
type: "boolean" type: "boolean",
default: true
}, },
newIsCapExceptions: { newIsCapExceptions: {
type: "array", type: "array",
@ -112,7 +114,8 @@ module.exports = {
type: "string" type: "string"
}, },
properties: { properties: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -126,7 +129,7 @@ module.exports = {
create(context) { create(context) {
const config = context.options[0] ? Object.assign({}, context.options[0]) : {}; const config = Object.assign({}, context.options[0]);
config.newIsCap = config.newIsCap !== false; config.newIsCap = config.newIsCap !== false;
config.capIsNew = config.capIsNew !== false; config.capIsNew = config.capIsNew !== false;

View File

@ -31,7 +31,8 @@ module.exports = {
ignoreChainWithDepth: { ignoreChainWithDepth: {
type: "integer", type: "integer",
minimum: 1, minimum: 1,
maximum: 10 maximum: 10,
default: 2
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -43,7 +43,8 @@ module.exports = {
uniqueItems: true uniqueItems: true
}, },
int32Hint: { int32Hint: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -41,7 +41,7 @@ module.exports = {
schema: [{ schema: [{
type: "object", type: "object",
properties: { properties: {
allowParens: { type: "boolean" } allowParens: { type: "boolean", default: false }
}, },
additionalProperties: false additionalProperties: false
}], }],

View File

@ -32,7 +32,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
checkLoops: { checkLoops: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -113,7 +113,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
includeExports: { includeExports: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -31,7 +31,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowElseIf: { allowElseIf: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -30,7 +30,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowEmptyCatch: { allowEmptyCatch: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -89,7 +89,7 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
allowIndirect: { type: "boolean" } allowIndirect: { type: "boolean", default: false }
}, },
additionalProperties: false additionalProperties: false
} }

View File

@ -44,11 +44,11 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
conditionalAssign: { type: "boolean" }, conditionalAssign: { type: "boolean", default: true },
nestedBinaryExpressions: { type: "boolean" }, nestedBinaryExpressions: { type: "boolean", default: true },
returnAssign: { type: "boolean" }, returnAssign: { type: "boolean", default: true },
ignoreJSX: { enum: ["none", "all", "single-line", "multi-line"] }, ignoreJSX: { enum: ["none", "all", "single-line", "multi-line"] },
enforceForArrowConditionals: { type: "boolean" } enforceForArrowConditionals: { type: "boolean", default: true }
}, },
additionalProperties: false additionalProperties: false
} }

View File

@ -69,7 +69,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
commentPattern: { commentPattern: {
type: "string" type: "string",
default: ""
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -21,9 +21,9 @@ const ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"];
*/ */
function parseOptions(options) { function parseOptions(options) {
return { return {
boolean: "boolean" in options ? Boolean(options.boolean) : true, boolean: "boolean" in options ? options.boolean : true,
number: "number" in options ? Boolean(options.number) : true, number: "number" in options ? options.number : true,
string: "string" in options ? Boolean(options.string) : true, string: "string" in options ? options.string : true,
allow: options.allow || [] allow: options.allow || []
}; };
} }
@ -167,13 +167,16 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
boolean: { boolean: {
type: "boolean" type: "boolean",
default: true
}, },
number: { number: {
type: "boolean" type: "boolean",
default: true
}, },
string: { string: {
type: "boolean" type: "boolean",
default: true
}, },
allow: { allow: {
type: "array", type: "array",

View File

@ -41,16 +41,20 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
skipComments: { skipComments: {
type: "boolean" type: "boolean",
default: false
}, },
skipStrings: { skipStrings: {
type: "boolean" type: "boolean",
default: true
}, },
skipTemplates: { skipTemplates: {
type: "boolean" type: "boolean",
default: false
}, },
skipRegExps: { skipRegExps: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -30,10 +30,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowLoop: { allowLoop: {
type: "boolean" type: "boolean",
default: false
}, },
allowSwitch: { allowSwitch: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -43,8 +45,8 @@ module.exports = {
create(context) { create(context) {
const options = context.options[0]; const options = context.options[0];
const allowLoop = Boolean(options && options.allowLoop); const allowLoop = options && options.allowLoop;
const allowSwitch = Boolean(options && options.allowSwitch); const allowSwitch = options && options.allowSwitch;
let scopeInfo = null; let scopeInfo = null;
/** /**

View File

@ -24,10 +24,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
detectObjects: { detectObjects: {
type: "boolean" type: "boolean",
default: false
}, },
enforceConst: { enforceConst: {
type: "boolean" type: "boolean",
default: false
}, },
ignore: { ignore: {
type: "array", type: "array",
@ -37,7 +39,8 @@ module.exports = {
uniqueItems: true uniqueItems: true
}, },
ignoreArrayIndexes: { ignoreArrayIndexes: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -42,10 +42,10 @@ const TARGET_NODE_TYPE = /^(?:Binary|Logical)Expression$/;
* @param {Object|undefined} options - A options object to normalize. * @param {Object|undefined} options - A options object to normalize.
* @returns {Object} Normalized option object. * @returns {Object} Normalized option object.
*/ */
function normalizeOptions(options) { function normalizeOptions(options = {}) {
const hasGroups = (options && options.groups && options.groups.length > 0); const hasGroups = options.groups && options.groups.length > 0;
const groups = hasGroups ? options.groups : DEFAULT_GROUPS; const groups = hasGroups ? options.groups : DEFAULT_GROUPS;
const allowSamePrecedence = (options && options.allowSamePrecedence) !== false; const allowSamePrecedence = options.allowSamePrecedence !== false;
return { return {
groups, groups,
@ -95,7 +95,8 @@ module.exports = {
uniqueItems: true uniqueItems: true
}, },
allowSamePrecedence: { allowSamePrecedence: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -30,10 +30,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
grouping: { grouping: {
type: "boolean" type: "boolean",
default: false
}, },
allowCall: { allowCall: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -38,7 +38,8 @@ module.exports = {
additionalProperties: false additionalProperties: false
}, },
ignoreEOLComments: { ignoreEOLComments: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -55,7 +55,7 @@ module.exports = {
}, },
create(context) { create(context) {
const props = context.options[0] && Boolean(context.options[0].props); const props = context.options[0] && context.options[0].props;
const ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || []; const ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || [];
/** /**

View File

@ -26,7 +26,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowForLoopAfterthoughts: { allowForLoopAfterthoughts: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -24,7 +24,7 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
builtinGlobals: { type: "boolean" } builtinGlobals: { type: "boolean", default: false }
}, },
additionalProperties: false additionalProperties: false
} }
@ -33,7 +33,7 @@ module.exports = {
create(context) { create(context) {
const options = { const options = {
builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals) builtinGlobals: context.options[0] && context.options[0].builtinGlobals
}; };
/** /**

View File

@ -179,7 +179,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
props: { props: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -4,6 +4,19 @@
*/ */
"use strict"; "use strict";
/**
* Determines if a variable safely shadows undefined.
* This is the case when a variable named `undefined` is never assigned to a value (i.e. it always shares the same value
* as the global).
* @param {eslintScope.Variable} variable The variable to check
* @returns {boolean} true if this variable safely shadows `undefined`
*/
function safelyShadowsUndefined(variable) {
return variable.name === "undefined" &&
variable.references.every(ref => !ref.isWrite()) &&
variable.defs.every(def => def.node.type === "VariableDeclarator" && def.node.init === null);
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Rule Definition // Rule Definition
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -24,12 +37,13 @@ module.exports = {
create(context) { create(context) {
const RESTRICTED = ["undefined", "NaN", "Infinity", "arguments", "eval"];
const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]);
return { return {
"VariableDeclaration, :function, CatchClause"(node) { "VariableDeclaration, :function, CatchClause"(node) {
for (const variable of context.getDeclaredVariables(node)) { for (const variable of context.getDeclaredVariables(node)) {
if (variable.defs.length > 0 && RESTRICTED.includes(variable.name)) { if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) {
context.report({ context.report({
node: variable.defs[0].name, node: variable.defs[0].name,
message: "Shadowing of global property '{{idName}}'.", message: "Shadowing of global property '{{idName}}'.",

View File

@ -30,8 +30,8 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
builtinGlobals: { type: "boolean" }, builtinGlobals: { type: "boolean", default: false },
hoist: { enum: ["all", "functions", "never"] }, hoist: { enum: ["all", "functions", "never"], default: "functions" },
allow: { allow: {
type: "array", type: "array",
items: { items: {
@ -47,7 +47,7 @@ module.exports = {
create(context) { create(context) {
const options = { const options = {
builtinGlobals: Boolean(context.options[0] && context.options[0].builtinGlobals), builtinGlobals: context.options[0] && context.options[0].builtinGlobals,
hoist: (context.options[0] && context.options[0].hoist) || "functions", hoist: (context.options[0] && context.options[0].hoist) || "functions",
allow: (context.options[0] && context.options[0].allow) || [] allow: (context.options[0] && context.options[0].allow) || []
}; };

View File

@ -27,7 +27,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowAtRootLevel: { allowAtRootLevel: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -30,7 +30,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowIndentationTabs: { allowIndentationTabs: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -32,10 +32,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
skipBlankLines: { skipBlankLines: {
type: "boolean" type: "boolean",
default: false
}, },
ignoreComments: { ignoreComments: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -52,7 +54,7 @@ module.exports = {
const options = context.options[0] || {}, const options = context.options[0] || {},
skipBlankLines = options.skipBlankLines || false, skipBlankLines = options.skipBlankLines || false,
ignoreComments = typeof options.ignoreComments === "boolean" && options.ignoreComments; ignoreComments = options.ignoreComments || false;
/** /**
* Report the error message * Report the error message

View File

@ -39,7 +39,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
typeof: { typeof: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -31,13 +31,16 @@ module.exports = {
} }
}, },
allowAfterThis: { allowAfterThis: {
type: "boolean" type: "boolean",
default: false
}, },
allowAfterSuper: { allowAfterSuper: {
type: "boolean" type: "boolean",
default: false
}, },
enforceInMethodNames: { enforceInMethodNames: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -38,7 +38,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
defaultAssignment: { defaultAssignment: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -24,13 +24,16 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowShortCircuit: { allowShortCircuit: {
type: "boolean" type: "boolean",
default: false
}, },
allowTernary: { allowTernary: {
type: "boolean" type: "boolean",
default: false
}, },
allowTaggedTemplates: { allowTaggedTemplates: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -37,22 +37,26 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
vars: { vars: {
enum: ["all", "local"] enum: ["all", "local"],
default: "all"
}, },
varsIgnorePattern: { varsIgnorePattern: {
type: "string" type: "string"
}, },
args: { args: {
enum: ["all", "after-used", "none"] enum: ["all", "after-used", "none"],
default: "after-used"
}, },
ignoreRestSiblings: { ignoreRestSiblings: {
type: "boolean" type: "boolean",
default: false
}, },
argsIgnorePattern: { argsIgnorePattern: {
type: "string" type: "string"
}, },
caughtErrors: { caughtErrors: {
enum: ["all", "none"] enum: ["all", "none"],
default: "none"
}, },
caughtErrorsIgnorePattern: { caughtErrorsIgnorePattern: {
type: "string" type: "string"

View File

@ -154,9 +154,9 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
functions: { type: "boolean" }, functions: { type: "boolean", default: true },
classes: { type: "boolean" }, classes: { type: "boolean", default: true },
variables: { type: "boolean" } variables: { type: "boolean", default: true }
}, },
additionalProperties: false additionalProperties: false
} }

View File

@ -26,9 +26,9 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
ignoreDestructuring: { type: "boolean" }, ignoreDestructuring: { type: "boolean", default: false },
ignoreImport: { type: "boolean" }, ignoreImport: { type: "boolean", default: false },
ignoreExport: { type: "boolean" } ignoreExport: { type: "boolean", default: false }
}, },
additionalProperties: false additionalProperties: false
} }

View File

@ -26,14 +26,16 @@ const OPTION_VALUE = {
type: "object", type: "object",
properties: { properties: {
multiline: { multiline: {
type: "boolean" type: "boolean",
default: false
}, },
minProperties: { minProperties: {
type: "integer", type: "integer",
minimum: 0 minimum: 0
}, },
consistent: { consistent: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false, additionalProperties: false,
@ -59,9 +61,9 @@ function normalizeOptionValue(value) {
} else if (value === "never") { } else if (value === "never") {
minProperties = Number.POSITIVE_INFINITY; minProperties = Number.POSITIVE_INFINITY;
} else { } else {
multiline = Boolean(value.multiline); multiline = value.multiline;
minProperties = value.minProperties || Number.POSITIVE_INFINITY; minProperties = value.minProperties || Number.POSITIVE_INFINITY;
consistent = Boolean(value.consistent); consistent = value.consistent;
} }
} else { } else {
consistent = true; consistent = true;

View File

@ -25,10 +25,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowAllPropertiesOnSameLine: { allowAllPropertiesOnSameLine: {
type: "boolean" type: "boolean",
default: false
}, },
allowMultiplePropertiesPerLine: { // Deprecated allowMultiplePropertiesPerLine: { // Deprecated
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -40,7 +42,7 @@ module.exports = {
create(context) { create(context) {
const allowSameLine = context.options[0] && ( const allowSameLine = context.options[0] && (
(Boolean(context.options[0].allowAllPropertiesOnSameLine) || Boolean(context.options[0].allowMultiplePropertiesPerLine)) // Deprecated (context.options[0].allowAllPropertiesOnSameLine || context.options[0].allowMultiplePropertiesPerLine /* Deprecated */)
); );
const errorMessage = allowSameLine const errorMessage = allowSameLine
? "Object properties must go on a new line if they aren't all on the same line." ? "Object properties must go on a new line if they aren't all on the same line."

View File

@ -57,7 +57,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
avoidQuotes: { avoidQuotes: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -76,13 +77,16 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
ignoreConstructors: { ignoreConstructors: {
type: "boolean" type: "boolean",
default: false
}, },
avoidQuotes: { avoidQuotes: {
type: "boolean" type: "boolean",
default: false
}, },
avoidExplicitReturnArrows: { avoidExplicitReturnArrows: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -32,16 +32,20 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
separateRequires: { separateRequires: {
type: "boolean" type: "boolean",
default: false
}, },
var: { var: {
enum: ["always", "never", "consecutive"] enum: ["always", "never", "consecutive"],
default: "always"
}, },
let: { let: {
enum: ["always", "never", "consecutive"] enum: ["always", "never", "consecutive"],
default: "always"
}, },
const: { const: {
enum: ["always", "never", "consecutive"] enum: ["always", "never", "consecutive"],
default: "always"
} }
}, },
additionalProperties: false additionalProperties: false
@ -76,42 +80,16 @@ module.exports = {
options.let = { uninitialized: mode, initialized: mode }; options.let = { uninitialized: mode, initialized: mode };
options.const = { uninitialized: mode, initialized: mode }; options.const = { uninitialized: mode, initialized: mode };
} else if (typeof mode === "object") { // options configuration is an object } else if (typeof mode === "object") { // options configuration is an object
if (Object.prototype.hasOwnProperty.call(mode, "separateRequires")) { options.separateRequires = mode.separateRequires;
options.separateRequires = !!mode.separateRequires; options.var = { uninitialized: mode.var, initialized: mode.var };
} options.let = { uninitialized: mode.let, initialized: mode.let };
if (Object.prototype.hasOwnProperty.call(mode, "var")) { options.const = { uninitialized: mode.const, initialized: mode.const };
options.var = { uninitialized: mode.var, initialized: mode.var };
}
if (Object.prototype.hasOwnProperty.call(mode, "let")) {
options.let = { uninitialized: mode.let, initialized: mode.let };
}
if (Object.prototype.hasOwnProperty.call(mode, "const")) {
options.const = { uninitialized: mode.const, initialized: mode.const };
}
if (Object.prototype.hasOwnProperty.call(mode, "uninitialized")) { if (Object.prototype.hasOwnProperty.call(mode, "uninitialized")) {
if (!options.var) {
options.var = {};
}
if (!options.let) {
options.let = {};
}
if (!options.const) {
options.const = {};
}
options.var.uninitialized = mode.uninitialized; options.var.uninitialized = mode.uninitialized;
options.let.uninitialized = mode.uninitialized; options.let.uninitialized = mode.uninitialized;
options.const.uninitialized = mode.uninitialized; options.const.uninitialized = mode.uninitialized;
} }
if (Object.prototype.hasOwnProperty.call(mode, "initialized")) { if (Object.prototype.hasOwnProperty.call(mode, "initialized")) {
if (!options.var) {
options.var = {};
}
if (!options.let) {
options.let = {};
}
if (!options.const) {
options.const = {};
}
options.var.initialized = mode.initialized; options.var.initialized = mode.initialized;
options.let.initialized = mode.initialized; options.let.initialized = mode.initialized;
options.const.initialized = mode.initialized; options.const.initialized = mode.initialized;
@ -257,7 +235,9 @@ module.exports = {
if (currentOptions.uninitialized === MODE_ALWAYS && currentOptions.initialized === MODE_ALWAYS) { if (currentOptions.uninitialized === MODE_ALWAYS && currentOptions.initialized === MODE_ALWAYS) {
if (currentScope.uninitialized || currentScope.initialized) { if (currentScope.uninitialized || currentScope.initialized) {
return false; if (!hasRequires) {
return false;
}
} }
} }
@ -268,7 +248,9 @@ module.exports = {
} }
if (declarationCounts.initialized > 0) { if (declarationCounts.initialized > 0) {
if (currentOptions.initialized === MODE_ALWAYS && currentScope.initialized) { if (currentOptions.initialized === MODE_ALWAYS && currentScope.initialized) {
return false; if (!hasRequires) {
return false;
}
} }
} }
if (currentScope.required && hasRequires) { if (currentScope.required && hasRequires) {
@ -340,7 +322,11 @@ module.exports = {
* y` * y`
* ^ afterComma * ^ afterComma
*/ */
if (afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line || afterComma.type === "Line" || afterComma.type === "Block") { if (
afterComma.loc.start.line > tokenAfterDeclarator.loc.end.line ||
afterComma.type === "Line" ||
afterComma.type === "Block"
) {
let lastComment = afterComma; let lastComment = afterComma;
while (lastComment.type === "Line" || lastComment.type === "Block") { while (lastComment.type === "Line" || lastComment.type === "Block") {
@ -349,7 +335,7 @@ module.exports = {
return fixer.replaceTextRange( return fixer.replaceTextRange(
[tokenAfterDeclarator.range[0], lastComment.range[0]], [tokenAfterDeclarator.range[0], lastComment.range[0]],
`;\n${sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0])}\n${declaration.kind} ` `;${sourceCode.text.slice(tokenAfterDeclarator.range[1], lastComment.range[0])}${declaration.kind} `
); );
} }

View File

@ -5,6 +5,12 @@
"use strict"; "use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("../util/ast-utils");
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Rule Definition // Rule Definition
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -45,32 +51,45 @@ module.exports = {
minProperties: 1 minProperties: 1
} }
] ]
},
{
type: "object",
properties: {
allowSingleLineBlocks: {
type: "boolean"
}
}
} }
] ]
}, },
create(context) { create(context) {
const options = {}; const options = {};
const config = context.options[0] || "always"; const typeOptions = context.options[0] || "always";
const exceptOptions = context.options[1] || {};
if (typeof config === "string") { if (typeof typeOptions === "string") {
const shouldHavePadding = config === "always"; const shouldHavePadding = typeOptions === "always";
options.blocks = shouldHavePadding; options.blocks = shouldHavePadding;
options.switches = shouldHavePadding; options.switches = shouldHavePadding;
options.classes = shouldHavePadding; options.classes = shouldHavePadding;
} else { } else {
if (Object.prototype.hasOwnProperty.call(config, "blocks")) { if (Object.prototype.hasOwnProperty.call(typeOptions, "blocks")) {
options.blocks = config.blocks === "always"; options.blocks = typeOptions.blocks === "always";
} }
if (Object.prototype.hasOwnProperty.call(config, "switches")) { if (Object.prototype.hasOwnProperty.call(typeOptions, "switches")) {
options.switches = config.switches === "always"; options.switches = typeOptions.switches === "always";
} }
if (Object.prototype.hasOwnProperty.call(config, "classes")) { if (Object.prototype.hasOwnProperty.call(typeOptions, "classes")) {
options.classes = config.classes === "always"; options.classes = typeOptions.classes === "always";
} }
} }
if (Object.prototype.hasOwnProperty.call(exceptOptions, "allowSingleLineBlocks")) {
options.allowSingleLineBlocks = exceptOptions.allowSingleLineBlocks === true;
}
const ALWAYS_MESSAGE = "Block must be padded by blank lines.", const ALWAYS_MESSAGE = "Block must be padded by blank lines.",
NEVER_MESSAGE = "Block must not be padded by blank lines."; NEVER_MESSAGE = "Block must not be padded by blank lines.";
@ -177,6 +196,10 @@ module.exports = {
blockHasTopPadding = isPaddingBetweenTokens(tokenBeforeFirst, firstBlockToken), blockHasTopPadding = isPaddingBetweenTokens(tokenBeforeFirst, firstBlockToken),
blockHasBottomPadding = isPaddingBetweenTokens(lastBlockToken, tokenAfterLast); blockHasBottomPadding = isPaddingBetweenTokens(lastBlockToken, tokenAfterLast);
if (options.allowSingleLineBlocks && astUtils.isTokenOnSameLine(tokenBeforeFirst, tokenAfterLast)) {
return;
}
if (requirePaddingFor(node)) { if (requirePaddingFor(node)) {
if (!blockHasTopPadding) { if (!blockHasTopPadding) {
context.report({ context.report({

View File

@ -146,10 +146,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
allowNamedFunctions: { allowNamedFunctions: {
type: "boolean" type: "boolean",
default: false
}, },
allowUnboundThis: { allowUnboundThis: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -345,8 +345,8 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
destructuring: { enum: ["any", "all"] }, destructuring: { enum: ["any", "all"], default: "any" },
ignoreReadBeforeAssign: { type: "boolean" } ignoreReadBeforeAssign: { type: "boolean", default: false }
}, },
additionalProperties: false additionalProperties: false
} }

View File

@ -19,6 +19,8 @@ module.exports = {
url: "https://eslint.org/docs/rules/prefer-destructuring" url: "https://eslint.org/docs/rules/prefer-destructuring"
}, },
fixable: "code",
schema: [ schema: [
{ {
@ -34,10 +36,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
array: { array: {
type: "boolean" type: "boolean",
default: true
}, },
object: { object: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -46,10 +50,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
array: { array: {
type: "boolean" type: "boolean",
default: true
}, },
object: { object: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -61,10 +67,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
array: { array: {
type: "boolean" type: "boolean",
default: true
}, },
object: { object: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -75,7 +83,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
enforceForRenamedProperties: { enforceForRenamedProperties: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -130,10 +139,55 @@ module.exports = {
* *
* @param {ASTNode} reportNode the node to report * @param {ASTNode} reportNode the node to report
* @param {string} type the type of destructuring that should have been done * @param {string} type the type of destructuring that should have been done
* @param {Function|null} fix the fix function or null to pass to context.report
* @returns {void} * @returns {void}
*/ */
function report(reportNode, type) { function report(reportNode, type, fix) {
context.report({ node: reportNode, message: "Use {{type}} destructuring.", data: { type } }); context.report({
node: reportNode,
message: "Use {{type}} destructuring.",
data: { type },
fix
});
}
/**
* Determines if a node should be fixed into object destructuring
*
* The fixer only fixes the simplest case of object destructuring,
* like: `let x = a.x`;
*
* Assignment expression is not fixed.
* Array destructuring is not fixed.
* Renamed property is not fixed.
*
* @param {ASTNode} node the the node to evaluate
* @returns {boolean} whether or not the node should be fixed
*/
function shouldFix(node) {
return node.type === "VariableDeclarator" &&
node.id.type === "Identifier" &&
node.init.type === "MemberExpression" &&
node.id.name === node.init.property.name;
}
/**
* Fix a node into object destructuring.
* This function only handles the simplest case of object destructuring,
* see {@link shouldFix}.
*
* @param {SourceCodeFixer} fixer the fixer object
* @param {ASTNode} node the node to be fixed.
* @returns {Object} a fix for the node
*/
function fixIntoObjectDestructuring(fixer, node) {
const rightNode = node.init;
const sourceCode = context.getSourceCode();
return fixer.replaceText(
node,
`{${rightNode.property.name}} = ${sourceCode.getText(rightNode.object)}`
);
} }
/** /**
@ -155,13 +209,17 @@ module.exports = {
if (isArrayIndexAccess(rightNode)) { if (isArrayIndexAccess(rightNode)) {
if (shouldCheck(reportNode.type, "array")) { if (shouldCheck(reportNode.type, "array")) {
report(reportNode, "array"); report(reportNode, "array", null);
} }
return; return;
} }
const fix = shouldFix(reportNode)
? fixer => fixIntoObjectDestructuring(fixer, reportNode)
: null;
if (shouldCheck(reportNode.type, "object") && enforceForRenamedProperties) { if (shouldCheck(reportNode.type, "object") && enforceForRenamedProperties) {
report(reportNode, "object"); report(reportNode, "object", fix);
return; return;
} }
@ -172,7 +230,7 @@ module.exports = {
(property.type === "Literal" && leftNode.name === property.value) || (property.type === "Literal" && leftNode.name === property.value) ||
(property.type === "Identifier" && leftNode.name === property.name && !rightNode.computed) (property.type === "Identifier" && leftNode.name === property.name && !rightNode.computed)
) { ) {
report(reportNode, "object"); report(reportNode, "object", fix);
} }
} }
} }

View File

@ -27,7 +27,7 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
allowEmptyReject: { type: "boolean" } allowEmptyReject: { type: "boolean", default: false }
}, },
additionalProperties: false additionalProperties: false
} }

View File

@ -59,7 +59,7 @@ module.exports = {
}, },
schema: [], schema: [],
fixable: "code" fixable: null
}, },
create(context) { create(context) {
@ -78,18 +78,7 @@ module.exports = {
if (isValidThisArg(expectedThis, thisArg, sourceCode)) { if (isValidThisArg(expectedThis, thisArg, sourceCode)) {
context.report({ context.report({
node, node,
message: "Use the spread operator instead of '.apply()'.", message: "Use the spread operator instead of '.apply()'."
fix(fixer) {
if (expectedThis && expectedThis.type !== "Identifier") {
// Don't fix cases where the `this` value could be a computed expression.
return null;
}
const propertyDot = sourceCode.getFirstTokenBetween(applied, node.callee.property, token => token.value === ".");
return fixer.replaceTextRange([propertyDot.range[0], node.range[1]], `(...${sourceCode.getText(node.arguments[1])})`);
}
}); });
} }
} }

View File

@ -32,7 +32,8 @@ module.exports = {
type: "array", type: "array",
items: [ items: [
{ {
enum: ["always", "as-needed", "consistent", "consistent-as-needed"] enum: ["always", "as-needed", "consistent", "consistent-as-needed"],
default: "always"
} }
], ],
minItems: 0, minItems: 0,
@ -42,19 +43,23 @@ module.exports = {
type: "array", type: "array",
items: [ items: [
{ {
enum: ["always", "as-needed", "consistent", "consistent-as-needed"] enum: ["always", "as-needed", "consistent", "consistent-as-needed"],
default: "always"
}, },
{ {
type: "object", type: "object",
properties: { properties: {
keywords: { keywords: {
type: "boolean" type: "boolean",
default: false
}, },
unnecessary: { unnecessary: {
type: "boolean" type: "boolean",
default: true
}, },
numbers: { numbers: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -100,10 +100,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
avoidEscape: { avoidEscape: {
type: "boolean" type: "boolean",
default: false
}, },
allowTemplateLiterals: { allowTemplateLiterals: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -23,22 +23,28 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
ClassDeclaration: { ClassDeclaration: {
type: "boolean" type: "boolean",
default: false
}, },
MethodDefinition: { MethodDefinition: {
type: "boolean" type: "boolean",
default: false
}, },
FunctionDeclaration: { FunctionDeclaration: {
type: "boolean" type: "boolean",
default: true
}, },
ArrowFunctionExpression: { ArrowFunctionExpression: {
type: "boolean" type: "boolean",
default: false
}, },
FunctionExpression: { FunctionExpression: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false,
default: {}
} }
}, },
additionalProperties: false additionalProperties: false
@ -58,7 +64,7 @@ module.exports = {
ArrowFunctionExpression: false, ArrowFunctionExpression: false,
FunctionExpression: false FunctionExpression: false
}; };
const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require || {}); const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require);
/** /**
* Report the error message * Report the error message

View File

@ -29,10 +29,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
before: { before: {
type: "boolean" type: "boolean",
default: false
}, },
after: { after: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false
@ -48,12 +50,8 @@ module.exports = {
requireSpaceAfter = true; requireSpaceAfter = true;
if (typeof config === "object") { if (typeof config === "object") {
if (Object.prototype.hasOwnProperty.call(config, "before")) { requireSpaceBefore = config.before;
requireSpaceBefore = config.before; requireSpaceAfter = config.after;
}
if (Object.prototype.hasOwnProperty.call(config, "after")) {
requireSpaceAfter = config.after;
}
} }
/** /**

View File

@ -40,7 +40,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
beforeStatementContinuationChars: { beforeStatementContinuationChars: {
enum: ["always", "any", "never"] enum: ["always", "any", "never"],
default: "any"
} }
}, },
additionalProperties: false additionalProperties: false
@ -58,7 +59,7 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
omitLastInOneLineBlock: { type: "boolean" } omitLastInOneLineBlock: { type: "boolean", default: false }
}, },
additionalProperties: false additionalProperties: false
} }
@ -75,8 +76,8 @@ module.exports = {
const OPT_OUT_PATTERN = /^[-[(/+`]/; // One of [(/+-` const OPT_OUT_PATTERN = /^[-[(/+`]/; // One of [(/+-`
const options = context.options[1]; const options = context.options[1];
const never = context.options[0] === "never"; const never = context.options[0] === "never";
const exceptOneLine = Boolean(options && options.omitLastInOneLineBlock); const exceptOneLine = options && options.omitLastInOneLineBlock;
const beforeStatementContinuationChars = (options && options.beforeStatementContinuationChars) || "any"; const beforeStatementContinuationChars = options && options.beforeStatementContinuationChars;
const sourceCode = context.getSourceCode(); const sourceCode = context.getSourceCode();
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------

View File

@ -25,7 +25,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
ignoreCase: { ignoreCase: {
type: "boolean" type: "boolean",
default: false
}, },
memberSyntaxSortOrder: { memberSyntaxSortOrder: {
type: "array", type: "array",
@ -37,10 +38,12 @@ module.exports = {
maxItems: 4 maxItems: 4
}, },
ignoreDeclarationSort: { ignoreDeclarationSort: {
type: "boolean" type: "boolean",
default: false
}, },
ignoreMemberSort: { ignoreMemberSort: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -90,10 +90,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
caseSensitive: { caseSensitive: {
type: "boolean" type: "boolean",
default: true
}, },
natural: { natural: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false
@ -106,8 +108,8 @@ module.exports = {
// Parse options. // Parse options.
const order = context.options[0] || "asc"; const order = context.options[0] || "asc";
const options = context.options[1]; const options = context.options[1];
const insensitive = (options && options.caseSensitive) === false; const insensitive = options && options.caseSensitive === false;
const natual = Boolean(options && options.natural); const natual = options && options.natural;
const isValidOrder = isValidOrders[ const isValidOrder = isValidOrders[
order + (insensitive ? "I" : "") + (natual ? "N" : "") order + (insensitive ? "I" : "") + (natual ? "N" : "")
]; ];
@ -127,8 +129,12 @@ module.exports = {
stack = stack.upper; stack = stack.upper;
}, },
SpreadElement() {
stack.prevName = null;
},
Property(node) { Property(node) {
if (node.parent.type === "ObjectPattern" || node.parent.properties.some(n => n.type === "SpreadElement")) { if (node.parent.type === "ObjectPattern") {
return; return;
} }

View File

@ -25,7 +25,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
ignoreCase: { ignoreCase: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -37,13 +37,16 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
anonymous: { anonymous: {
enum: ["always", "never", "ignore"] enum: ["always", "never", "ignore"],
default: "always"
}, },
named: { named: {
enum: ["always", "never", "ignore"] enum: ["always", "never", "ignore"],
default: "always"
}, },
asyncArrow: { asyncArrow: {
enum: ["always", "never", "ignore"] enum: ["always", "never", "ignore"],
default: "always"
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -26,7 +26,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
int32Hint: { int32Hint: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -32,10 +32,12 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
words: { words: {
type: "boolean" type: "boolean",
default: true
}, },
nonwords: { nonwords: {
type: "boolean" type: "boolean",
default: false
}, },
overrides: { overrides: {
type: "object", type: "object",
@ -58,7 +60,7 @@ module.exports = {
}, },
create(context) { create(context) {
const options = context.options && Array.isArray(context.options) && context.options[0] || { words: true, nonwords: false }; const options = context.options[0] || { words: true, nonwords: false };
const sourceCode = context.getSourceCode(); const sourceCode = context.getSourceCode();

View File

@ -215,7 +215,8 @@ module.exports = {
} }
}, },
balanced: { balanced: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -30,8 +30,8 @@ module.exports = {
{ {
type: "object", type: "object",
properties: { properties: {
before: { type: "boolean" }, before: { type: "boolean", default: false },
after: { type: "boolean" } after: { type: "boolean", default: true }
}, },
additionalProperties: false additionalProperties: false
} }

View File

@ -42,22 +42,27 @@ module.exports = {
} }
}, },
requireReturn: { requireReturn: {
type: "boolean" type: "boolean",
default: true
}, },
requireParamDescription: { requireParamDescription: {
type: "boolean" type: "boolean",
default: true
}, },
requireReturnDescription: { requireReturnDescription: {
type: "boolean" type: "boolean",
default: true
}, },
matchDescription: { matchDescription: {
type: "string" type: "string"
}, },
requireReturnType: { requireReturnType: {
type: "boolean" type: "boolean",
default: true
}, },
requireParamType: { requireParamType: {
type: "boolean" type: "boolean",
default: true
} }
}, },
additionalProperties: false additionalProperties: false

View File

@ -24,7 +24,8 @@ module.exports = {
type: "object", type: "object",
properties: { properties: {
requireStringLiterals: { requireStringLiterals: {
type: "boolean" type: "boolean",
default: false
} }
}, },
additionalProperties: false additionalProperties: false

Some files were not shown because too many files have changed in this diff Show More