@ospm/eslint-plugin-react-signals-hooks
Version:
ESLint plugin for React Signals hooks - enforces best practices, performance optimizations, and integration patterns for @preact/signals-react usage in React projects
29 lines • 1.11 kB
JavaScript
import { AST_NODE_TYPES } from "@typescript-eslint/types";
export function getPreferredQuote(sourceCode) {
const first = sourceCode.ast.body[0];
if (typeof first !== "undefined" &&
first.type === AST_NODE_TYPES.ImportDeclaration) {
return sourceCode.getText(first.source).startsWith('"') ? '"' : "'";
}
return "'";
}
export function getPreferredSemicolon(sourceCode) {
const firstImport = sourceCode.ast.body.find((n) => {
return n.type === AST_NODE_TYPES.ImportDeclaration;
});
if (typeof firstImport !== "undefined") {
return sourceCode.getText(firstImport).trimEnd().endsWith(";");
}
const firstStmt = sourceCode.ast.body[0];
if (typeof firstStmt !== "undefined") {
const raw = sourceCode.getText(firstStmt).trimEnd();
if (raw.length > 0) {
return raw.endsWith(";");
}
}
return true;
}
export function buildNamedImport(moduleName, names, quote, semi) {
return `import { ${names.join(", ")} } from ${quote}${moduleName}${quote}${semi ? ";" : ""}\n`;
}
//# sourceMappingURL=import-format.js.map