Enable unicorn/prefer-optional-catch-binding (#9464)
This commit is contained in:
1 parent
feacf82892
commit
64a3906571
14 files changed
+27
-23
No files matched your search
@@ -73,6 +73,7 @@ rules:
|
||||
unicorn/no-useless-undefined: error
|
||||
unicorn/prefer-includes: error
|
||||
unicorn/prefer-number-properties: error
|
||||
unicorn/prefer-optional-catch-binding: error
|
||||
unicorn/prefer-regexp-test: error
|
||||
unicorn/prefer-spread: error
|
||||
unicorn/prefer-string-slice: error
|
||||
|
||||
@@ -127,7 +127,7 @@ async function cacheFiles(cache) {
|
||||
path.join(".cache", file.replace("dist", "files")),
|
||||
]);
|
||||
}
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// Don't fail the build
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,10 +110,13 @@ function getBabelConfig(bundle) {
|
||||
},
|
||||
],
|
||||
];
|
||||
config.plugins.push([
|
||||
require.resolve("@babel/plugin-proposal-object-rest-spread"),
|
||||
{ loose: true, useBuiltIns: true },
|
||||
]);
|
||||
config.plugins.push(
|
||||
[
|
||||
require.resolve("@babel/plugin-proposal-object-rest-spread"),
|
||||
{ loose: true, useBuiltIns: true },
|
||||
],
|
||||
require.resolve("@babel/plugin-proposal-optional-catch-binding")
|
||||
);
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class Cache {
|
||||
for (const files of Object.values(this.files)) {
|
||||
assert.ok(Array.isArray(files));
|
||||
}
|
||||
} catch (err) {
|
||||
} catch {
|
||||
this.checksums = {};
|
||||
this.files = {};
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class Cache {
|
||||
async save() {
|
||||
try {
|
||||
await fs.writeFile(this.manifest, JSON.stringify(this.updated, null, 2));
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// Don't fail the build
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -165,7 +165,7 @@ function format(context, input, opt) {
|
||||
let benchmark;
|
||||
try {
|
||||
benchmark = eval("require")("benchmark");
|
||||
} catch (err) {
|
||||
} catch {
|
||||
context.logger.debug(
|
||||
"'--debug-benchmark' requires the 'benchmark' package to be installed."
|
||||
);
|
||||
|
||||
@@ -45,7 +45,7 @@ function load(plugins, pluginSearchDirs) {
|
||||
try {
|
||||
// try local files
|
||||
requirePath = resolve(path.resolve(process.cwd(), pluginName));
|
||||
} catch (_) {
|
||||
} catch {
|
||||
// try node modules
|
||||
requirePath = resolve(pluginName, { paths: [process.cwd()] });
|
||||
}
|
||||
@@ -120,7 +120,7 @@ function findPluginsInNodeModules(nodeModulesDir) {
|
||||
function isDirectory(dir) {
|
||||
try {
|
||||
return fs.statSync(dir).isDirectory();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ function parseValue(value, options) {
|
||||
|
||||
try {
|
||||
result = valueParser(value, { loose: true }).parse();
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return {
|
||||
type: "value-unknown",
|
||||
value,
|
||||
@@ -247,7 +247,7 @@ function parseSelector(selector) {
|
||||
selectorParser((result_) => {
|
||||
result = result_;
|
||||
}).process(selector);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Fail silently. It's better to print it as is than to try and parse it
|
||||
// Note: A common failure is for SCSS nested properties. `background:
|
||||
// none { color: red; }` is parsed as a NestedDeclaration by
|
||||
@@ -270,7 +270,7 @@ function parseMediaQuery(params) {
|
||||
|
||||
try {
|
||||
result = mediaParser(params);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Ignore bad media queries
|
||||
/* istanbul ignore next */
|
||||
return {
|
||||
|
||||
@@ -39,7 +39,7 @@ function parseIeConditionalStartEndComment(node, parseHtml, match) {
|
||||
const [complete, children] = (() => {
|
||||
try {
|
||||
return [true, parseHtml(data, contentStartSpan).children];
|
||||
} catch (e) {
|
||||
} catch {
|
||||
const text = {
|
||||
type: "text",
|
||||
value: data,
|
||||
|
||||
@@ -1172,7 +1172,7 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
||||
"}}",
|
||||
])
|
||||
);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
parts.push("{{", replaceEndOfLineWith(part, literalline), "}}");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -128,7 +128,7 @@ function getInterpreter(filepath) {
|
||||
let fd;
|
||||
try {
|
||||
fd = fs.openSync(filepath, "r");
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// istanbul ignore next
|
||||
return "";
|
||||
}
|
||||
@@ -149,7 +149,7 @@ function getInterpreter(filepath) {
|
||||
return m2[1];
|
||||
}
|
||||
return "";
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// There are some weird cases where paths are missing, causing Jest
|
||||
// failures. It's unclear what these correspond to in the real world.
|
||||
/* istanbul ignore next */
|
||||
@@ -159,7 +159,7 @@ function getInterpreter(filepath) {
|
||||
// There are some weird cases where paths are missing, causing Jest
|
||||
// failures. It's unclear what these correspond to in the real world.
|
||||
fs.closeSync(fd);
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// nop
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ function resolveParser(opts, parsers = getParsers(opts)) {
|
||||
locStart,
|
||||
locEnd,
|
||||
};
|
||||
} catch (err) {
|
||||
} catch {
|
||||
/* istanbul ignore next */
|
||||
throw new ConfigError(`Couldn't resolve parser "${opts.parser}"`);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export function get(key) {
|
||||
try {
|
||||
return JSON.parse(window.localStorage.getItem(key));
|
||||
} catch (_) {
|
||||
} catch {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export function get(key) {
|
||||
export function set(key, value) {
|
||||
try {
|
||||
window.localStorage.setItem(key, JSON.stringify(value));
|
||||
} catch (_) {
|
||||
} catch {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export function read() {
|
||||
|
||||
try {
|
||||
return JSON.parse(decode(hash));
|
||||
} catch (_) {
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ function handleMessage(message) {
|
||||
if (!errored) {
|
||||
try {
|
||||
ast = formatCode(ast, { parser: "json", plugins }).formatted;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
ast = serializeAst(ast);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user