mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
tools: update eslint to 8.40.0
PR-URL: https://github.com/nodejs/node/pull/47906 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
35d1def891
commit
52532c2cb1
1134 files changed
+1916
-1505
No files matched your search
+57
-35
@@ -126,32 +126,65 @@ function normalizeRuleOptions(ruleOptions) {
|
||||
// Assertions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The error type when a rule's options are configured with an invalid type.
|
||||
*/
|
||||
class InvalidRuleOptionsError extends Error {
|
||||
|
||||
/**
|
||||
* @param {string} ruleId Rule name being configured.
|
||||
* @param {any} value The invalid value.
|
||||
*/
|
||||
constructor(ruleId, value) {
|
||||
super(`Key "${ruleId}": Expected severity of "off", 0, "warn", 1, "error", or 2.`);
|
||||
this.messageTemplate = "invalid-rule-options";
|
||||
this.messageData = { ruleId, value };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a valid rule options entry.
|
||||
* @param {string} ruleId Rule name being configured.
|
||||
* @param {any} value The value to check.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value isn't a valid rule options.
|
||||
* @throws {InvalidRuleOptionsError} If the value isn't a valid rule options.
|
||||
*/
|
||||
function assertIsRuleOptions(value) {
|
||||
|
||||
function assertIsRuleOptions(ruleId, value) {
|
||||
if (typeof value !== "string" && typeof value !== "number" && !Array.isArray(value)) {
|
||||
throw new TypeError("Expected a string, number, or array.");
|
||||
throw new InvalidRuleOptionsError(ruleId, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The error type when a rule's severity is invalid.
|
||||
*/
|
||||
class InvalidRuleSeverityError extends Error {
|
||||
|
||||
/**
|
||||
* @param {string} ruleId Rule name being configured.
|
||||
* @param {any} value The invalid value.
|
||||
*/
|
||||
constructor(ruleId, value) {
|
||||
super(`Key "${ruleId}": Expected severity of "off", 0, "warn", 1, "error", or 2.`);
|
||||
this.messageTemplate = "invalid-rule-severity";
|
||||
this.messageData = { ruleId, value };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is valid rule severity.
|
||||
* @param {string} ruleId Rule name being configured.
|
||||
* @param {any} value The value to check.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value isn't a valid rule severity.
|
||||
* @throws {InvalidRuleSeverityError} If the value isn't a valid rule severity.
|
||||
*/
|
||||
function assertIsRuleSeverity(value) {
|
||||
function assertIsRuleSeverity(ruleId, value) {
|
||||
const severity = typeof value === "string"
|
||||
? ruleSeverities.get(value.toLowerCase())
|
||||
: ruleSeverities.get(value);
|
||||
|
||||
if (typeof severity === "undefined") {
|
||||
throw new TypeError("Expected severity of \"off\", 0, \"warn\", 1, \"error\", or 2.");
|
||||
throw new InvalidRuleSeverityError(ruleId, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,39 +390,28 @@ const rulesSchema = {
|
||||
validate(value) {
|
||||
assertIsObject(value);
|
||||
|
||||
let lastRuleId;
|
||||
/*
|
||||
* We are not checking the rule schema here because there is no
|
||||
* guarantee that the rule definition is present at this point. Instead
|
||||
* we wait and check the rule schema during the finalization step
|
||||
* of calculating a config.
|
||||
*/
|
||||
for (const ruleId of Object.keys(value)) {
|
||||
|
||||
// Performance: One try-catch has less overhead than one per loop iteration
|
||||
try {
|
||||
// avoid hairy edge case
|
||||
if (ruleId === "__proto__") {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* We are not checking the rule schema here because there is no
|
||||
* guarantee that the rule definition is present at this point. Instead
|
||||
* we wait and check the rule schema during the finalization step
|
||||
* of calculating a config.
|
||||
*/
|
||||
for (const ruleId of Object.keys(value)) {
|
||||
const ruleOptions = value[ruleId];
|
||||
|
||||
// avoid hairy edge case
|
||||
if (ruleId === "__proto__") {
|
||||
continue;
|
||||
}
|
||||
assertIsRuleOptions(ruleId, ruleOptions);
|
||||
|
||||
lastRuleId = ruleId;
|
||||
|
||||
const ruleOptions = value[ruleId];
|
||||
|
||||
assertIsRuleOptions(ruleOptions);
|
||||
|
||||
if (Array.isArray(ruleOptions)) {
|
||||
assertIsRuleSeverity(ruleOptions[0]);
|
||||
} else {
|
||||
assertIsRuleSeverity(ruleOptions);
|
||||
}
|
||||
if (Array.isArray(ruleOptions)) {
|
||||
assertIsRuleSeverity(ruleId, ruleOptions[0]);
|
||||
} else {
|
||||
assertIsRuleSeverity(ruleId, ruleOptions);
|
||||
}
|
||||
} catch (error) {
|
||||
error.message = `Key "${lastRuleId}": ${error.message}`;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+56
-16
@@ -320,6 +320,45 @@ async function loadFlatConfigFile(filePath) {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines which config file to use. This is determined by seeing if an
|
||||
* override config file was passed, and if so, using it; otherwise, as long
|
||||
* as override config file is not explicitly set to `false`, it will search
|
||||
* upwards from the cwd for a file named `eslint.config.js`.
|
||||
* @param {import("./eslint").ESLintOptions} options The ESLint instance options.
|
||||
* @returns {{configFilePath:string,basePath:string,error:boolean}} Location information for
|
||||
* the config file.
|
||||
*/
|
||||
async function locateConfigFileToUse({ configFile, cwd }) {
|
||||
|
||||
// determine where to load config file from
|
||||
let configFilePath;
|
||||
let basePath = cwd;
|
||||
let error = false;
|
||||
|
||||
if (typeof configFile === "string") {
|
||||
debug(`Override config file path is ${configFile}`);
|
||||
configFilePath = path.resolve(cwd, configFile);
|
||||
} else if (configFile !== false) {
|
||||
debug("Searching for eslint.config.js");
|
||||
configFilePath = await findFlatConfigFile(cwd);
|
||||
|
||||
if (configFilePath) {
|
||||
basePath = path.resolve(path.dirname(configFilePath));
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
configFilePath,
|
||||
basePath,
|
||||
error
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the config array for this run based on inputs.
|
||||
* @param {FlatESLint} eslint The instance to create the config array for.
|
||||
@@ -342,25 +381,13 @@ async function calculateConfigArray(eslint, {
|
||||
return slots.configs;
|
||||
}
|
||||
|
||||
// determine where to load config file from
|
||||
let configFilePath;
|
||||
let basePath = cwd;
|
||||
const { configFilePath, basePath, error } = await locateConfigFileToUse({ configFile, cwd });
|
||||
|
||||
if (typeof configFile === "string") {
|
||||
debug(`Override config file path is ${configFile}`);
|
||||
configFilePath = path.resolve(cwd, configFile);
|
||||
} else if (configFile !== false) {
|
||||
debug("Searching for eslint.config.js");
|
||||
configFilePath = await findFlatConfigFile(cwd);
|
||||
|
||||
if (!configFilePath) {
|
||||
throw new Error("Could not find config file.");
|
||||
}
|
||||
|
||||
basePath = path.resolve(path.dirname(configFilePath));
|
||||
// config file is required to calculate config
|
||||
if (error) {
|
||||
throw new Error("Could not find config file.");
|
||||
}
|
||||
|
||||
|
||||
const configs = new FlatConfigArray(baseConfig || [], { basePath, shouldIgnore });
|
||||
|
||||
// load config file
|
||||
@@ -1160,6 +1187,19 @@ class FlatESLint {
|
||||
return configs.getConfig(absolutePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the config file being used by this instance based on the options
|
||||
* passed to the constructor.
|
||||
* @returns {string|undefined} The path to the config file being used or
|
||||
* `undefined` if no config file is being used.
|
||||
*/
|
||||
async findConfigFile() {
|
||||
const options = privateMembers.get(this).options;
|
||||
const { configFilePath } = await locateConfigFileToUse(options);
|
||||
|
||||
return configFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given path is ignored by ESLint.
|
||||
* @param {string} filePath The path of the file to check.
|
||||
|
||||
+6
-2
@@ -592,7 +592,7 @@ function findEslintEnv(text) {
|
||||
* Convert "/path/to/<text>" to "<text>".
|
||||
* `CLIEngine#executeOnText()` method gives "/path/to/<text>" if the filename
|
||||
* was omitted because `configArray.extractConfig()` requires an absolute path.
|
||||
* But the linter should pass `<text>` to `RuleContext#getFilename()` in that
|
||||
* But the linter should pass `<text>` to `RuleContext#filename` in that
|
||||
* case.
|
||||
* Also, code blocks can have their virtual filename. If the parent filename was
|
||||
* `<text>`, the virtual filename is `<text>/0_foo.js` or something like (i.e.,
|
||||
@@ -902,7 +902,7 @@ const BASE_TRAVERSAL_CONTEXT = Object.freeze(
|
||||
(contextInfo, methodName) =>
|
||||
Object.assign(contextInfo, {
|
||||
[methodName](...args) {
|
||||
return this.getSourceCode()[DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName]](...args);
|
||||
return this.sourceCode[DEPRECATED_SOURCECODE_PASSTHROUGHS[methodName]](...args);
|
||||
}
|
||||
}),
|
||||
{}
|
||||
@@ -951,10 +951,14 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserName, languageO
|
||||
getAncestors: () => sourceCode.getAncestors(currentNode),
|
||||
getDeclaredVariables: node => sourceCode.getDeclaredVariables(node),
|
||||
getCwd: () => cwd,
|
||||
cwd,
|
||||
getFilename: () => filename,
|
||||
filename,
|
||||
getPhysicalFilename: () => physicalFilename || filename,
|
||||
physicalFilename: physicalFilename || filename,
|
||||
getScope: () => sourceCode.getScope(currentNode),
|
||||
getSourceCode: () => sourceCode,
|
||||
sourceCode,
|
||||
markVariableAsUsed: name => sourceCode.markVariableAsUsed(name, currentNode),
|
||||
parserOptions: {
|
||||
...languageOptions.parserOptions
|
||||
|
||||
+2
-2
@@ -142,7 +142,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce getter and setter pairs in objects and classes",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/accessor-pairs"
|
||||
url: "https://eslint.org/docs/latest/rules/accessor-pairs"
|
||||
},
|
||||
|
||||
schema: [{
|
||||
@@ -178,7 +178,7 @@ module.exports = {
|
||||
const checkGetWithoutSet = config.getWithoutSet === true;
|
||||
const checkSetWithoutGet = config.setWithoutGet !== false;
|
||||
const enforceForClassMembers = config.enforceForClassMembers !== false;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Reports the given node.
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce linebreaks after opening and before closing array brackets",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/array-bracket-newline"
|
||||
url: "https://eslint.org/docs/latest/rules/array-bracket-newline"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -56,7 +56,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent spacing inside array brackets",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/array-bracket-spacing"
|
||||
url: "https://eslint.org/docs/latest/rules/array-bracket-spacing"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -53,7 +53,7 @@ module.exports = {
|
||||
},
|
||||
create(context) {
|
||||
const spaced = context.options[0] === "always",
|
||||
sourceCode = context.getSourceCode();
|
||||
sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Determines whether an option is set, relative to the spacing option.
|
||||
|
||||
+2
-2
@@ -141,7 +141,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce `return` statements in callbacks of array methods",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/array-callback-return"
|
||||
url: "https://eslint.org/docs/latest/rules/array-callback-return"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -172,7 +172,7 @@ module.exports = {
|
||||
create(context) {
|
||||
|
||||
const options = context.options[0] || { allowImplicit: false, checkForEach: false };
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
let funcInfo = {
|
||||
arrayMethodName: null,
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce line breaks after each array element",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/array-element-newline"
|
||||
url: "https://eslint.org/docs/latest/rules/array-element-newline"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -79,7 +79,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require braces around arrow function bodies",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/arrow-body-style"
|
||||
url: "https://eslint.org/docs/latest/rules/arrow-body-style"
|
||||
},
|
||||
|
||||
schema: {
|
||||
@@ -74,7 +74,7 @@ module.exports = {
|
||||
const asNeeded = !options[0] || options[0] === "as-needed";
|
||||
const never = options[0] === "never";
|
||||
const requireReturnForObjectLiteral = options[1] && options[1].requireReturnForObjectLiteral;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
let funcInfo = null;
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require parentheses around arrow function arguments",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/arrow-parens"
|
||||
url: "https://eslint.org/docs/latest/rules/arrow-parens"
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
@@ -69,7 +69,7 @@ module.exports = {
|
||||
const asNeeded = context.options[0] === "as-needed";
|
||||
const requireForBlockBody = asNeeded && context.options[1] && context.options[1].requireForBlockBody === true;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Finds opening paren of parameters for the given arrow function, if it exists.
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before and after the arrow in arrow functions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/arrow-spacing"
|
||||
url: "https://eslint.org/docs/latest/rules/arrow-spacing"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -61,7 +61,7 @@ module.exports = {
|
||||
rule.before = rule.before !== false;
|
||||
rule.after = rule.after !== false;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Get tokens of arrow(`=>`) and before/after arrow.
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce the use of variables within the scope they are defined",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/block-scoped-var"
|
||||
url: "https://eslint.org/docs/latest/rules/block-scoped-var"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
@@ -28,7 +28,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
let stack = [];
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Makes a block scope.
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow or enforce spaces inside of blocks after opening block and before closing block",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/block-spacing"
|
||||
url: "https://eslint.org/docs/latest/rules/block-spacing"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -37,7 +37,7 @@ module.exports = {
|
||||
create(context) {
|
||||
const always = (context.options[0] !== "never"),
|
||||
messageId = always ? "missing" : "extra",
|
||||
sourceCode = context.getSourceCode();
|
||||
sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Gets the open brace token from a given node.
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent brace style for blocks",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/brace-style"
|
||||
url: "https://eslint.org/docs/latest/rules/brace-style"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -53,7 +53,7 @@ module.exports = {
|
||||
create(context) {
|
||||
const style = context.options[0] || "1tbs",
|
||||
params = context.options[1] || {},
|
||||
sourceCode = context.getSourceCode();
|
||||
sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require `return` statements after callbacks",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/callback-return"
|
||||
url: "https://eslint.org/docs/latest/rules/callback-return"
|
||||
},
|
||||
|
||||
schema: [{
|
||||
@@ -37,7 +37,7 @@ module.exports = {
|
||||
create(context) {
|
||||
|
||||
const callbacks = context.options[0] || ["callback", "cb", "next"],
|
||||
sourceCode = context.getSourceCode();
|
||||
sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce camelcase naming convention",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/camelcase"
|
||||
url: "https://eslint.org/docs/latest/rules/camelcase"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -73,7 +73,7 @@ module.exports = {
|
||||
const ignoreImports = options.ignoreImports;
|
||||
const ignoreGlobals = options.ignoreGlobals;
|
||||
const allow = options.allow || [];
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+2
-2
@@ -107,7 +107,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce or disallow capitalization of the first letter of a comment",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/capitalized-comments"
|
||||
url: "https://eslint.org/docs/latest/rules/capitalized-comments"
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
@@ -139,7 +139,7 @@ module.exports = {
|
||||
|
||||
const capitalize = context.options[0] || "always",
|
||||
normalizedOptions = getAllNormalizedOptions(context.options[1]),
|
||||
sourceCode = context.getSourceCode();
|
||||
sourceCode = context.sourceCode;
|
||||
|
||||
createRegExpForIgnorePatterns(normalizedOptions);
|
||||
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce that class methods utilize `this`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/class-methods-use-this"
|
||||
url: "https://eslint.org/docs/latest/rules/class-methods-use-this"
|
||||
},
|
||||
|
||||
schema: [{
|
||||
@@ -133,7 +133,7 @@ module.exports = {
|
||||
if (isIncludedInstanceMethod(node.parent) && !methodUsesThis) {
|
||||
context.report({
|
||||
node,
|
||||
loc: astUtils.getFunctionHeadLoc(node, context.getSourceCode()),
|
||||
loc: astUtils.getFunctionHeadLoc(node, context.sourceCode),
|
||||
messageId: "missingThis",
|
||||
data: {
|
||||
name: astUtils.getFunctionNameWithKind(node)
|
||||
|
||||
+2
-2
@@ -78,7 +78,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require or disallow trailing commas",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/comma-dangle"
|
||||
url: "https://eslint.org/docs/latest/rules/comma-dangle"
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
@@ -136,7 +136,7 @@ module.exports = {
|
||||
create(context) {
|
||||
const options = normalizeOptions(context.options[0], context.languageOptions.ecmaVersion);
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Gets the last item of the given node.
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before and after commas",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/comma-spacing"
|
||||
url: "https://eslint.org/docs/latest/rules/comma-spacing"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -48,7 +48,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const tokensAndComments = sourceCode.tokensAndComments;
|
||||
|
||||
const options = {
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent comma style",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/comma-style"
|
||||
url: "https://eslint.org/docs/latest/rules/comma-style"
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
@@ -51,7 +51,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
const style = context.options[0] || "last",
|
||||
sourceCode = context.getSourceCode();
|
||||
sourceCode = context.sourceCode;
|
||||
const exceptions = {
|
||||
ArrayPattern: true,
|
||||
ArrowFunctionExpression: true,
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum cyclomatic complexity allowed in a program",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/complexity"
|
||||
url: "https://eslint.org/docs/latest/rules/complexity"
|
||||
},
|
||||
|
||||
schema: [
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent spacing inside computed property brackets",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/computed-property-spacing"
|
||||
url: "https://eslint.org/docs/latest/rules/computed-property-spacing"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -49,7 +49,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never"
|
||||
const enforceForClassMembers = !context.options[1] || context.options[1].enforceForClassMembers;
|
||||
|
||||
|
||||
+3
-3
@@ -48,7 +48,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require `return` statements to either always or never specify values",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/consistent-return"
|
||||
url: "https://eslint.org/docs/latest/rules/consistent-return"
|
||||
},
|
||||
|
||||
schema: [{
|
||||
@@ -104,7 +104,7 @@ module.exports = {
|
||||
} else if (node.type === "ArrowFunctionExpression") {
|
||||
|
||||
// `=>` token
|
||||
loc = context.getSourceCode().getTokenBefore(node.body, astUtils.isArrowToken).loc;
|
||||
loc = context.sourceCode.getTokenBefore(node.body, astUtils.isArrowToken).loc;
|
||||
} else if (
|
||||
node.parent.type === "MethodDefinition" ||
|
||||
(node.parent.type === "Property" && node.parent.method)
|
||||
@@ -115,7 +115,7 @@ module.exports = {
|
||||
} else {
|
||||
|
||||
// Function name or `function` keyword.
|
||||
loc = (node.id || context.getSourceCode().getFirstToken(node)).loc;
|
||||
loc = (node.id || context.sourceCode.getFirstToken(node)).loc;
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent naming when capturing the current execution context",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/consistent-this"
|
||||
url: "https://eslint.org/docs/latest/rules/consistent-this"
|
||||
},
|
||||
|
||||
schema: {
|
||||
@@ -36,7 +36,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
let aliases = [];
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
if (context.options.length === 0) {
|
||||
aliases.push("that");
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require `super()` calls in constructors",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/constructor-super"
|
||||
url: "https://eslint.org/docs/latest/rules/constructor-super"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent brace style for all control statements",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/curly"
|
||||
url: "https://eslint.org/docs/latest/rules/curly"
|
||||
},
|
||||
|
||||
schema: {
|
||||
@@ -70,7 +70,7 @@ module.exports = {
|
||||
const multiOrNest = (context.options[0] === "multi-or-nest");
|
||||
const consistent = (context.options[1] === "consistent");
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce default clauses in switch statements to be last",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/default-case-last"
|
||||
url: "https://eslint.org/docs/latest/rules/default-case-last"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require `default` cases in `switch` statements",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/default-case"
|
||||
url: "https://eslint.org/docs/latest/rules/default-case"
|
||||
},
|
||||
|
||||
schema: [{
|
||||
@@ -42,7 +42,7 @@ module.exports = {
|
||||
? new RegExp(options.commentPattern, "u")
|
||||
: DEFAULT_COMMENT_PATTERN;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce default parameters to be last",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/default-param-last"
|
||||
url: "https://eslint.org/docs/latest/rules/default-param-last"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent newlines before and after dots",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/dot-location"
|
||||
url: "https://eslint.org/docs/latest/rules/dot-location"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -43,7 +43,7 @@ module.exports = {
|
||||
// default to onObject if no preference is passed
|
||||
const onObject = config === "object" || !config;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Reports if the dot between object and property is on the correct location.
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce dot notation whenever possible",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/dot-notation"
|
||||
url: "https://eslint.org/docs/latest/rules/dot-notation"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -59,7 +59,7 @@ module.exports = {
|
||||
create(context) {
|
||||
const options = context.options[0] || {};
|
||||
const allowKeywords = options.allowKeywords === void 0 || options.allowKeywords;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
let allowPattern;
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require or disallow newline at the end of files",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/eol-last"
|
||||
url: "https://eslint.org/docs/latest/rules/eol-last"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -40,7 +40,7 @@ module.exports = {
|
||||
|
||||
return {
|
||||
Program: function checkBadEOF(node) {
|
||||
const sourceCode = context.getSourceCode(),
|
||||
const sourceCode = context.sourceCode,
|
||||
src = sourceCode.getText(),
|
||||
lastLine = sourceCode.lines[sourceCode.lines.length - 1],
|
||||
location = {
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require the use of `===` and `!==`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/eqeqeq"
|
||||
url: "https://eslint.org/docs/latest/rules/eqeqeq"
|
||||
},
|
||||
|
||||
schema: {
|
||||
@@ -68,7 +68,7 @@ module.exports = {
|
||||
create(context) {
|
||||
const config = context.options[0] || "always";
|
||||
const options = context.options[1] || {};
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
const nullOption = (config === "always")
|
||||
? options.null || "always"
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce \"for\" loop update clause moving the counter in the right direction",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/for-direction"
|
||||
url: "https://eslint.org/docs/latest/rules/for-direction"
|
||||
},
|
||||
|
||||
fixable: null,
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require or disallow spacing between function identifiers and their invocations",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/func-call-spacing"
|
||||
url: "https://eslint.org/docs/latest/rules/func-call-spacing"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -73,7 +73,7 @@ module.exports = {
|
||||
|
||||
const never = context.options[0] !== "always";
|
||||
const allowNewlines = !never && context.options[1] && context.options[1].allowNewlines;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const text = sourceCode.getText();
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require function names to match the name of the variable or property to which they are assigned",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/func-name-matching"
|
||||
url: "https://eslint.org/docs/latest/rules/func-name-matching"
|
||||
},
|
||||
|
||||
schema: {
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require or disallow named `function` expressions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/func-names"
|
||||
url: "https://eslint.org/docs/latest/rules/func-names"
|
||||
},
|
||||
|
||||
schema: {
|
||||
@@ -69,7 +69,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Returns the config option for the given node.
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce the consistent use of either `function` declarations or expressions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/func-style"
|
||||
url: "https://eslint.org/docs/latest/rules/func-style"
|
||||
},
|
||||
|
||||
schema: [
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce line breaks between arguments of a function call",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/function-call-argument-newline"
|
||||
url: "https://eslint.org/docs/latest/rules/function-call-argument-newline"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -35,7 +35,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
const checkers = {
|
||||
unexpected: {
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent line breaks inside function parentheses",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/function-paren-newline"
|
||||
url: "https://eslint.org/docs/latest/rules/function-paren-newline"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -57,7 +57,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const rawOption = context.options[0] || "multiline";
|
||||
const multilineOption = rawOption === "multiline";
|
||||
const multilineArgumentsOption = rawOption === "multiline-arguments";
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent spacing around `*` operators in generator functions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/generator-star-spacing"
|
||||
url: "https://eslint.org/docs/latest/rules/generator-star-spacing"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -102,7 +102,7 @@ module.exports = {
|
||||
};
|
||||
}(context.options[0] || {}));
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Checks if the given token is a star token or not.
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce `return` statements in getters",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/getter-return"
|
||||
url: "https://eslint.org/docs/latest/rules/getter-return"
|
||||
},
|
||||
|
||||
fixable: null,
|
||||
@@ -64,7 +64,7 @@ module.exports = {
|
||||
create(context) {
|
||||
|
||||
const options = context.options[0] || { allowImplicit: false };
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
let funcInfo = {
|
||||
upper: null,
|
||||
|
||||
+2
-2
@@ -61,7 +61,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require `require()` calls to be placed at top-level module scope",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/global-require"
|
||||
url: "https://eslint.org/docs/latest/rules/global-require"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
@@ -71,7 +71,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
CallExpression(node) {
|
||||
|
||||
+2
-2
@@ -98,7 +98,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require grouped accessor pairs in object literals and classes",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/grouped-accessor-pairs"
|
||||
url: "https://eslint.org/docs/latest/rules/grouped-accessor-pairs"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -115,7 +115,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
const order = context.options[0] || "anyOrder";
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Reports the given accessor pair.
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require `for-in` loops to include an `if` statement",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/guard-for-in"
|
||||
url: "https://eslint.org/docs/latest/rules/guard-for-in"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require error handling in callbacks",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/handle-callback-err"
|
||||
url: "https://eslint.org/docs/latest/rules/handle-callback-err"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -38,7 +38,7 @@ module.exports = {
|
||||
create(context) {
|
||||
|
||||
const errorArgument = context.options[0] || "err";
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Checks if the given argument should be interpreted as a regexp pattern.
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow specified identifiers",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/id-blacklist"
|
||||
url: "https://eslint.org/docs/latest/rules/id-blacklist"
|
||||
},
|
||||
|
||||
schema: {
|
||||
@@ -140,7 +140,7 @@ module.exports = {
|
||||
|
||||
const denyList = new Set(context.options);
|
||||
const reportedNodes = new Set();
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
let globalScope;
|
||||
|
||||
|
||||
+2
-2
@@ -101,7 +101,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow specified identifiers",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/id-denylist"
|
||||
url: "https://eslint.org/docs/latest/rules/id-denylist"
|
||||
},
|
||||
|
||||
schema: {
|
||||
@@ -121,7 +121,7 @@ module.exports = {
|
||||
|
||||
const denyList = new Set(context.options);
|
||||
const reportedNodes = new Set();
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
let globalScope;
|
||||
|
||||
|
||||
+3
-36
@@ -9,41 +9,8 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
const GraphemeSplitter = require("grapheme-splitter");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks if the string given as argument is ASCII or not.
|
||||
* @param {string} value A string that you want to know if it is ASCII or not.
|
||||
* @returns {boolean} `true` if `value` is ASCII string.
|
||||
*/
|
||||
function isASCII(value) {
|
||||
if (typeof value !== "string") {
|
||||
return false;
|
||||
}
|
||||
return /^[\u0020-\u007f]*$/u.test(value);
|
||||
}
|
||||
|
||||
/** @type {GraphemeSplitter | undefined} */
|
||||
let splitter;
|
||||
|
||||
/**
|
||||
* Gets the length of the string. If the string is not in ASCII, counts graphemes.
|
||||
* @param {string} value A string that you want to get the length.
|
||||
* @returns {number} The length of `value`.
|
||||
*/
|
||||
function getStringLength(value) {
|
||||
if (isASCII(value)) {
|
||||
return value.length;
|
||||
}
|
||||
if (!splitter) {
|
||||
splitter = new GraphemeSplitter();
|
||||
}
|
||||
return splitter.countGraphemes(value);
|
||||
}
|
||||
const { getGraphemeCount } = require("../shared/string-utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
@@ -57,7 +24,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce minimum and maximum identifier lengths",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/id-length"
|
||||
url: "https://eslint.org/docs/latest/rules/id-length"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -169,7 +136,7 @@ module.exports = {
|
||||
const name = node.name;
|
||||
const parent = node.parent;
|
||||
|
||||
const nameLength = getStringLength(name);
|
||||
const nameLength = getGraphemeCount(name);
|
||||
|
||||
const isShort = nameLength < minLength;
|
||||
const isLong = nameLength > maxLength;
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require identifiers to match a specified regular expression",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/id-match"
|
||||
url: "https://eslint.org/docs/latest/rules/id-match"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -67,7 +67,7 @@ module.exports = {
|
||||
onlyDeclarations = !!options.onlyDeclarations,
|
||||
ignoreDestructuring = !!options.ignoreDestructuring;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
let globalScope;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce the location of arrow function bodies",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/implicit-arrow-linebreak"
|
||||
url: "https://eslint.org/docs/latest/rules/implicit-arrow-linebreak"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -34,7 +34,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0] || "beside";
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent indentation",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/indent-legacy"
|
||||
url: "https://eslint.org/docs/latest/rules/indent-legacy"
|
||||
},
|
||||
|
||||
deprecated: true,
|
||||
@@ -206,7 +206,7 @@ module.exports = {
|
||||
ObjectExpression: 1
|
||||
};
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
if (context.options.length) {
|
||||
if (context.options[0] === "tab") {
|
||||
|
||||
+2
-2
@@ -510,7 +510,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent indentation",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/indent"
|
||||
url: "https://eslint.org/docs/latest/rules/indent"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -703,7 +703,7 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const tokenInfo = new TokenInfo(sourceCode);
|
||||
const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t");
|
||||
const parameterParens = new WeakSet();
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require or disallow initialization in variable declarations",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/init-declarations"
|
||||
url: "https://eslint.org/docs/latest/rules/init-declarations"
|
||||
},
|
||||
|
||||
schema: {
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce the consistent use of either double or single quotes in JSX attributes",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/jsx-quotes"
|
||||
url: "https://eslint.org/docs/latest/rules/jsx-quotes"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
|
||||
+4
-10
@@ -9,13 +9,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
const astUtils = require("./utils/ast-utils");
|
||||
const GraphemeSplitter = require("grapheme-splitter");
|
||||
|
||||
const splitter = new GraphemeSplitter();
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
const { getGraphemeCount } = require("../shared/string-utils");
|
||||
|
||||
/**
|
||||
* Checks whether a string contains a line terminator as defined in
|
||||
@@ -144,7 +138,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent spacing between keys and values in object literal properties",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/key-spacing"
|
||||
url: "https://eslint.org/docs/latest/rules/key-spacing"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -332,7 +326,7 @@ module.exports = {
|
||||
singleLineOptions = ruleOptions.singleLine,
|
||||
alignmentOptions = ruleOptions.align || null;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Determines if the given property is key-value property.
|
||||
@@ -523,7 +517,7 @@ module.exports = {
|
||||
const startToken = sourceCode.getFirstToken(property);
|
||||
const endToken = getLastTokenBeforeColon(property.key);
|
||||
|
||||
return splitter.countGraphemes(sourceCode.getText().slice(startToken.range[0], endToken.range[1]));
|
||||
return getGraphemeCount(sourceCode.getText().slice(startToken.range[0], endToken.range[1]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -69,7 +69,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent spacing before and after keywords",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/keyword-spacing"
|
||||
url: "https://eslint.org/docs/latest/rules/keyword-spacing"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -108,7 +108,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
const tokensToIgnore = new WeakSet();
|
||||
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce position of line comments",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/line-comment-position"
|
||||
url: "https://eslint.org/docs/latest/rules/line-comment-position"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -78,7 +78,7 @@ module.exports = {
|
||||
const defaultIgnoreRegExp = astUtils.COMMENTS_IGNORE_PATTERN;
|
||||
const fallThroughRegExp = /^\s*falls?\s?through/u;
|
||||
const customIgnoreRegExp = new RegExp(ignorePattern, "u");
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce consistent linebreak style",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/linebreak-style"
|
||||
url: "https://eslint.org/docs/latest/rules/linebreak-style"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -40,7 +40,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require empty lines around comments",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/lines-around-comment"
|
||||
url: "https://eslint.org/docs/latest/rules/lines-around-comment"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -138,7 +138,7 @@ module.exports = {
|
||||
|
||||
options.beforeBlockComment = typeof options.beforeBlockComment !== "undefined" ? options.beforeBlockComment : true;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
const lines = sourceCode.lines,
|
||||
numLines = lines.length + 1,
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require or disallow newlines around directives",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/lines-around-directive"
|
||||
url: "https://eslint.org/docs/latest/rules/lines-around-directive"
|
||||
},
|
||||
|
||||
schema: [{
|
||||
@@ -54,7 +54,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const config = context.options[0] || "always";
|
||||
const expectLineBefore = typeof config === "string" ? config : config.before;
|
||||
const expectLineAfter = typeof config === "string" ? config : config.after;
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require or disallow an empty line between class members",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/lines-between-class-members"
|
||||
url: "https://eslint.org/docs/latest/rules/lines-between-class-members"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -55,7 +55,7 @@ module.exports = {
|
||||
options[0] = context.options[0] || "always";
|
||||
options[1] = context.options[1] || { exceptAfterSingleLine: false };
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Gets a pair of tokens that should be used to check lines between two class member nodes.
|
||||
|
||||
+2
-2
@@ -161,7 +161,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require or disallow logical assignment operator shorthand",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/logical-assignment-operators"
|
||||
url: "https://eslint.org/docs/latest/rules/logical-assignment-operators"
|
||||
},
|
||||
|
||||
schema: {
|
||||
@@ -205,7 +205,7 @@ module.exports = {
|
||||
create(context) {
|
||||
const mode = context.options[0] === "never" ? "never" : "always";
|
||||
const checkIf = mode === "always" && context.options.length > 1 && context.options[1].enforceForIfStatements;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const isStrict = sourceCode.getScope(sourceCode.ast).isStrict;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum number of classes per file",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/max-classes-per-file"
|
||||
url: "https://eslint.org/docs/latest/rules/max-classes-per-file"
|
||||
},
|
||||
|
||||
schema: [
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum depth that blocks can be nested",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/max-depth"
|
||||
url: "https://eslint.org/docs/latest/rules/max-depth"
|
||||
},
|
||||
|
||||
schema: [
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum line length",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/max-len"
|
||||
url: "https://eslint.org/docs/latest/rules/max-len"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -97,7 +97,7 @@ module.exports = {
|
||||
*/
|
||||
const URL_REGEXP = /[^:/?#]:\/\/[^?#]/u;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Computes the length of a line that may contain tabs. The width of each
|
||||
|
||||
+2
-2
@@ -73,7 +73,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum number of lines of code in a function",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/max-lines-per-function"
|
||||
url: "https://eslint.org/docs/latest/rules/max-lines-per-function"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -85,7 +85,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const lines = sourceCode.lines;
|
||||
|
||||
const option = context.options[0];
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum number of lines per file",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/max-lines"
|
||||
url: "https://eslint.org/docs/latest/rules/max-lines"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -87,7 +87,7 @@ module.exports = {
|
||||
const skipComments = option && option.skipComments;
|
||||
const skipBlankLines = option && option.skipBlankLines;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Returns whether or not a token is a comment node type
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum depth that callbacks can be nested",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/max-nested-callbacks"
|
||||
url: "https://eslint.org/docs/latest/rules/max-nested-callbacks"
|
||||
},
|
||||
|
||||
schema: [
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum number of parameters in function definitions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/max-params"
|
||||
url: "https://eslint.org/docs/latest/rules/max-params"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -57,7 +57,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0];
|
||||
let numParams = 3;
|
||||
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum number of statements allowed per line",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/max-statements-per-line"
|
||||
url: "https://eslint.org/docs/latest/rules/max-statements-per-line"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -45,7 +45,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
|
||||
const sourceCode = context.getSourceCode(),
|
||||
const sourceCode = context.sourceCode,
|
||||
options = context.options[0] || {},
|
||||
maxStatementsPerLine = typeof options.max !== "undefined" ? options.max : 1;
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a maximum number of statements allowed in function blocks",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/max-statements"
|
||||
url: "https://eslint.org/docs/latest/rules/max-statements"
|
||||
},
|
||||
|
||||
schema: [
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce a particular style for multiline comments",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/multiline-comment-style"
|
||||
url: "https://eslint.org/docs/latest/rules/multiline-comment-style"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -65,7 +65,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0] || "starred-block";
|
||||
const params = context.options[1] || {};
|
||||
const checkJSDoc = !!params.checkJSDoc;
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce newlines between operands of ternary expressions",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/multiline-ternary"
|
||||
url: "https://eslint.org/docs/latest/rules/multiline-ternary"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -39,7 +39,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
const option = context.options[0];
|
||||
const multiline = option !== "never";
|
||||
const allowSingleLine = option === "always-multiline";
|
||||
|
||||
+2
-2
@@ -84,7 +84,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require constructor names to begin with a capital letter",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/new-cap"
|
||||
url: "https://eslint.org/docs/latest/rules/new-cap"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -147,7 +147,7 @@ module.exports = {
|
||||
|
||||
const listeners = {};
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Enforce or disallow parentheses when invoking a constructor with no arguments",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/new-parens"
|
||||
url: "https://eslint.org/docs/latest/rules/new-parens"
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
@@ -46,7 +46,7 @@ module.exports = {
|
||||
const options = context.options;
|
||||
const always = options[0] !== "never"; // Default is always
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
NewExpression(node) {
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require or disallow an empty line after variable declarations",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/newline-after-var"
|
||||
url: "https://eslint.org/docs/latest/rules/newline-after-var"
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
@@ -43,7 +43,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
// Default `mode` to "always".
|
||||
const mode = context.options[0] === "never" ? "never" : "always";
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require an empty line before `return` statements",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/newline-before-return"
|
||||
url: "https://eslint.org/docs/latest/rules/newline-before-return"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -31,7 +31,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Require a newline after each call in a method chain",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/newline-per-chained-call"
|
||||
url: "https://eslint.org/docs/latest/rules/newline-per-chained-call"
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
@@ -47,7 +47,7 @@ module.exports = {
|
||||
const options = context.options[0] || {},
|
||||
ignoreChainWithDepth = options.ignoreChainWithDepth || 2;
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Get the prefix of a given MemberExpression node.
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow the use of `alert`, `confirm`, and `prompt`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-alert"
|
||||
url: "https://eslint.org/docs/latest/rules/no-alert"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
@@ -101,7 +101,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
CallExpression(node) {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow `Array` constructors",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-array-constructor"
|
||||
url: "https://eslint.org/docs/latest/rules/no-array-constructor"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow using an async function as a Promise executor",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/no-async-promise-executor"
|
||||
url: "https://eslint.org/docs/latest/rules/no-async-promise-executor"
|
||||
},
|
||||
|
||||
fixable: null,
|
||||
@@ -30,7 +30,7 @@ module.exports = {
|
||||
return {
|
||||
"NewExpression[callee.name='Promise'][arguments.0.async=true]"(node) {
|
||||
context.report({
|
||||
node: context.getSourceCode().getFirstToken(node.arguments[0], token => token.value === "async"),
|
||||
node: context.sourceCode.getFirstToken(node.arguments[0], token => token.value === "async"),
|
||||
messageId: "async"
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow `await` inside of loops",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-await-in-loop"
|
||||
url: "https://eslint.org/docs/latest/rules/no-await-in-loop"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow bitwise operators",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-bitwise"
|
||||
url: "https://eslint.org/docs/latest/rules/no-bitwise"
|
||||
},
|
||||
|
||||
schema: [
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow use of the `Buffer()` constructor",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-buffer-constructor"
|
||||
url: "https://eslint.org/docs/latest/rules/no-buffer-constructor"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow the use of `arguments.caller` or `arguments.callee`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-caller"
|
||||
url: "https://eslint.org/docs/latest/rules/no-caller"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow lexical declarations in case clauses",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/no-case-declarations"
|
||||
url: "https://eslint.org/docs/latest/rules/no-case-declarations"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow `catch` clause parameters from shadowing variables in the outer scope",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-catch-shadow"
|
||||
url: "https://eslint.org/docs/latest/rules/no-catch-shadow"
|
||||
},
|
||||
|
||||
replacedBy: ["no-shadow"],
|
||||
@@ -39,7 +39,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Helpers
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow reassigning class members",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/no-class-assign"
|
||||
url: "https://eslint.org/docs/latest/rules/no-class-assign"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
@@ -31,7 +31,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Finds and reports references that are non initializer and writable.
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow comparing against -0",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/no-compare-neg-zero"
|
||||
url: "https://eslint.org/docs/latest/rules/no-compare-neg-zero"
|
||||
},
|
||||
|
||||
fixable: null,
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow assignment operators in conditional expressions",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/no-cond-assign"
|
||||
url: "https://eslint.org/docs/latest/rules/no-cond-assign"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -57,7 +57,7 @@ module.exports = {
|
||||
|
||||
const prohibitAssign = (context.options[0] || "except-parens");
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Check whether an AST node is the test expression for a conditional statement.
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow arrow functions where they could be confused with comparisons",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-confusing-arrow"
|
||||
url: "https://eslint.org/docs/latest/rules/no-confusing-arrow"
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
@@ -56,7 +56,7 @@ module.exports = {
|
||||
const config = context.options[0] || {};
|
||||
const allowParens = config.allowParens || (config.allowParens === void 0);
|
||||
const onlyOneSimpleParam = config.onlyOneSimpleParam;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow the use of `console`",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-console"
|
||||
url: "https://eslint.org/docs/latest/rules/no-console"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -51,7 +51,7 @@ module.exports = {
|
||||
create(context) {
|
||||
const options = context.options[0] || {};
|
||||
const allowed = options.allow || [];
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Checks whether the given reference is 'console' or not.
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow reassigning `const` variables",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/no-const-assign"
|
||||
url: "https://eslint.org/docs/latest/rules/no-const-assign"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
@@ -31,7 +31,7 @@ module.exports = {
|
||||
|
||||
create(context) {
|
||||
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Finds and reports references that are non initializer and writable.
|
||||
|
||||
+2
-2
@@ -441,7 +441,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow expressions where the operation doesn't affect the value",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-constant-binary-expression"
|
||||
url: "https://eslint.org/docs/latest/rules/no-constant-binary-expression"
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
@@ -453,7 +453,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
return {
|
||||
LogicalExpression(node) {
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow constant expressions in conditions",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/no-constant-condition"
|
||||
url: "https://eslint.org/docs/latest/rules/no-constant-condition"
|
||||
},
|
||||
|
||||
schema: [
|
||||
@@ -48,7 +48,7 @@ module.exports = {
|
||||
const options = context.options[0] || {},
|
||||
checkLoops = options.checkLoops !== false,
|
||||
loopSetStack = [];
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
let loopsInCurrentScope = new Set();
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow returning value from constructor",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-constructor-return"
|
||||
url: "https://eslint.org/docs/latest/rules/no-constructor-return"
|
||||
},
|
||||
|
||||
schema: {},
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow `continue` statements",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/rules/no-continue"
|
||||
url: "https://eslint.org/docs/latest/rules/no-continue"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ module.exports = {
|
||||
docs: {
|
||||
description: "Disallow control characters in regular expressions",
|
||||
recommended: true,
|
||||
url: "https://eslint.org/docs/rules/no-control-regex"
|
||||
url: "https://eslint.org/docs/latest/rules/no-control-regex"
|
||||
},
|
||||
|
||||
schema: [],
|
||||
|
||||
Loaded 100 of 1134 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user