@truenine/eslint9-config
Version:
ESLint 9 configuration package for Compose Client projects with TypeScript, Vue, and modern JavaScript support
47 lines (45 loc) • 1.48 kB
JavaScript
let node_module = require("node:module");
//#region src/rules/code-style/brace-style.ts
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
let originalRule = {};
try {
originalRule = require$1("@stylistic/eslint-plugin").rules["brace-style"];
} catch (e) {
console.error("Failed to load @stylistic/eslint-plugin/brace-style", e);
}
const rule = {
meta: {
...originalRule?.meta,
docs: {
...originalRule?.meta?.docs,
description: "Custom brace style that enforces 1tbs but allows separate lines for try-catch-finally"
}
},
create(context) {
if (!originalRule?.create) return {};
const { sourceCode } = context;
return originalRule.create(Object.create(context, { report: {
value: (descriptor) => {
const { node, loc } = descriptor;
const startLoc = loc ? loc.start : node ? node.loc.start : null;
if (startLoc) {
const index = sourceCode.getIndexFromLoc(startLoc);
const token = sourceCode.getTokenByRangeStart(index);
if (token) {
if (token.value === "catch" || token.value === "finally") return;
if (token.value === "}") {
const nextToken = sourceCode.getTokenAfter(token);
if (nextToken && (nextToken.value === "catch" || nextToken.value === "finally")) return;
}
}
}
context.report(descriptor);
},
writable: false,
configurable: false
} }));
}
};
//#endregion
module.exports = rule;
//# sourceMappingURL=brace-style.cjs.map