eslint
Advanced tools
Comparing version 8.21.0 to 8.22.0
@@ -142,23 +142,38 @@ /** | ||
const { plugins, languageOptions, processor } = config; | ||
let parserName, processorName; | ||
let invalidParser = false, | ||
invalidProcessor = false; | ||
// Check parser value | ||
if (languageOptions && languageOptions.parser && typeof languageOptions.parser === "string") { | ||
const { pluginName, objectName: parserName } = splitPluginIdentifier(languageOptions.parser); | ||
if (languageOptions && languageOptions.parser) { | ||
if (typeof languageOptions.parser === "string") { | ||
const { pluginName, objectName: localParserName } = splitPluginIdentifier(languageOptions.parser); | ||
if (!plugins || !plugins[pluginName] || !plugins[pluginName].parsers || !plugins[pluginName].parsers[parserName]) { | ||
throw new TypeError(`Key "parser": Could not find "${parserName}" in plugin "${pluginName}".`); | ||
parserName = languageOptions.parser; | ||
if (!plugins || !plugins[pluginName] || !plugins[pluginName].parsers || !plugins[pluginName].parsers[localParserName]) { | ||
throw new TypeError(`Key "parser": Could not find "${localParserName}" in plugin "${pluginName}".`); | ||
} | ||
languageOptions.parser = plugins[pluginName].parsers[localParserName]; | ||
} else { | ||
invalidParser = true; | ||
} | ||
languageOptions.parser = plugins[pluginName].parsers[parserName]; | ||
} | ||
// Check processor value | ||
if (processor && typeof processor === "string") { | ||
const { pluginName, objectName: processorName } = splitPluginIdentifier(processor); | ||
if (processor) { | ||
if (typeof processor === "string") { | ||
const { pluginName, objectName: localProcessorName } = splitPluginIdentifier(processor); | ||
if (!plugins || !plugins[pluginName] || !plugins[pluginName].processors || !plugins[pluginName].processors[processorName]) { | ||
throw new TypeError(`Key "processor": Could not find "${processorName}" in plugin "${pluginName}".`); | ||
processorName = processor; | ||
if (!plugins || !plugins[pluginName] || !plugins[pluginName].processors || !plugins[pluginName].processors[localProcessorName]) { | ||
throw new TypeError(`Key "processor": Could not find "${localProcessorName}" in plugin "${pluginName}".`); | ||
} | ||
config.processor = plugins[pluginName].processors[localProcessorName]; | ||
} else { | ||
invalidProcessor = true; | ||
} | ||
config.processor = plugins[pluginName].processors[processorName]; | ||
} | ||
@@ -168,2 +183,28 @@ | ||
// apply special logic for serialization into JSON | ||
/* eslint-disable object-shorthand -- shorthand would change "this" value */ | ||
Object.defineProperty(config, "toJSON", { | ||
value: function() { | ||
if (invalidParser) { | ||
throw new Error("Caching is not supported when parser is an object."); | ||
} | ||
if (invalidProcessor) { | ||
throw new Error("Caching is not supported when processor is an object."); | ||
} | ||
return { | ||
...this, | ||
plugins: Object.keys(plugins), | ||
languageOptions: { | ||
...languageOptions, | ||
parser: parserName | ||
}, | ||
processor: processorName | ||
}; | ||
} | ||
}); | ||
/* eslint-enable object-shorthand -- ok to enable now */ | ||
return config; | ||
@@ -170,0 +211,0 @@ } |
@@ -439,5 +439,2 @@ /** | ||
} | ||
if (cache) { | ||
errors.push("'cache' option is not yet supported."); | ||
} | ||
if (!isNonEmptyString(cacheLocation)) { | ||
@@ -444,0 +441,0 @@ errors.push("'cacheLocation' must be a non-empty string."); |
@@ -33,2 +33,3 @@ /** | ||
findFiles, | ||
getCacheFile, | ||
@@ -45,2 +46,3 @@ isNonEmptyString, | ||
const { FlatConfigArray } = require("../config/flat-config-array"); | ||
const LintResultCache = require("../cli-engine/lint-result-cache"); | ||
@@ -611,5 +613,16 @@ /* | ||
const cacheFilePath = getCacheFile( | ||
processedOptions.cacheLocation, | ||
processedOptions.cwd | ||
); | ||
const lintResultCache = processedOptions.cache | ||
? new LintResultCache(cacheFilePath, processedOptions.cacheStrategy) | ||
: null; | ||
privateMembers.set(this, { | ||
options: processedOptions, | ||
linter, | ||
cacheFilePath, | ||
lintResultCache, | ||
defaultConfigs, | ||
@@ -788,2 +801,4 @@ defaultIgnores: () => false, | ||
if (!cache && cacheFilePath) { | ||
debug(`Deleting cache file at ${cacheFilePath}`); | ||
try { | ||
@@ -790,0 +805,0 @@ await fs.unlink(cacheFilePath); |
@@ -81,2 +81,5 @@ /** | ||
}, | ||
methodsIgnorePattern: { | ||
type: "string" | ||
}, | ||
avoidQuotes: { | ||
@@ -119,2 +122,5 @@ type: "boolean" | ||
const IGNORE_CONSTRUCTORS = PARAMS.ignoreConstructors; | ||
const METHODS_IGNORE_PATTERN = PARAMS.methodsIgnorePattern | ||
? new RegExp(PARAMS.methodsIgnorePattern, "u") | ||
: null; | ||
const AVOID_QUOTES = PARAMS.avoidQuotes; | ||
@@ -462,2 +468,11 @@ const AVOID_EXPLICIT_RETURN_ARROWS = !!PARAMS.avoidExplicitReturnArrows; | ||
} | ||
if (METHODS_IGNORE_PATTERN) { | ||
const propertyName = astUtils.getStaticPropertyName(node); | ||
if (propertyName !== null && METHODS_IGNORE_PATTERN.test(propertyName)) { | ||
return; | ||
} | ||
} | ||
if (AVOID_QUOTES && isStringLiteral(node.key)) { | ||
@@ -464,0 +479,0 @@ return; |
{ | ||
"name": "eslint", | ||
"version": "8.21.0", | ||
"version": "8.22.0", | ||
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>", | ||
@@ -42,3 +42,4 @@ "description": "An AST-based pattern checker for JavaScript.", | ||
"git add docs/src/_data/further_reading_links.json" | ||
] | ||
], | ||
"docs/**/*.svg": "npx svgo -r --multipass" | ||
}, | ||
@@ -45,0 +46,0 @@ "files": [ |
2796986
66494