ifc-language-server/node_modules/@stylistic/eslint-plugin/dist/rules/jsx-equals-spacing.js
Ryan Schultz 8afacf268a Implemented a working Language Server Protocol (LSP) for IFC files with:
- Hover provider showing entity information and type
- Go-to-definition (F12) for entity references
- Basic IFC file validation (ISO-10303-21 header check)
- Entity parsing with regex-based detection
- Proper CommonJS module system (avoiding ES module issues)

This replaces the broken baseline from ifc-developer-tools which had:
- Non-functional ES module configuration
- Circular dependency issues
- Parser crashes
- Non-working PositionVisitor

Built on Microsoft's LSP example template for a clean, maintainable foundation.

Next: Add hierarchical entity dependency tree in hover tooltip."
2025-12-07 10:20:07 -06:00

91 lines
2.7 KiB
JavaScript

'use strict';
var utils = require('../utils.js');
require('eslint-visitor-keys');
require('espree');
require('estraverse');
const messages = {
noSpaceBefore: "There should be no space before '='",
noSpaceAfter: "There should be no space after '='",
needSpaceBefore: "A space is required before '='",
needSpaceAfter: "A space is required after '='"
};
var jsxEqualsSpacing = utils.createRule({
name: "jsx-equals-spacing",
package: "jsx",
meta: {
type: "layout",
docs: {
description: "Enforce or disallow spaces around equal signs in JSX attributes"
},
fixable: "code",
messages,
schema: [
{
type: "string",
enum: ["always", "never"]
}
]
},
create(context) {
const config = context.options[0] || "never";
return {
JSXOpeningElement(node) {
node.attributes.forEach((attrNode) => {
if (!(attrNode.type !== "JSXSpreadAttribute" && attrNode.value !== null))
return;
const sourceCode = context.sourceCode;
const equalToken = sourceCode.getTokenAfter(attrNode.name);
const spacedBefore = sourceCode.isSpaceBetweenTokens(attrNode.name, equalToken);
const spacedAfter = sourceCode.isSpaceBetweenTokens(equalToken, attrNode.value);
if (config === "never") {
if (spacedBefore) {
context.report({
node: attrNode,
messageId: "noSpaceBefore",
loc: equalToken.loc.start,
fix(fixer) {
return fixer.removeRange([attrNode.name.range[1], equalToken.range[0]]);
}
});
}
if (spacedAfter) {
context.report({
node: attrNode,
messageId: "noSpaceAfter",
loc: equalToken.loc.start,
fix(fixer) {
return fixer.removeRange([equalToken.range[1], attrNode.value.range[0]]);
}
});
}
} else if (config === "always") {
if (!spacedBefore) {
context.report({
messageId: "needSpaceBefore",
node: attrNode,
loc: equalToken.loc.start,
fix(fixer) {
return fixer.insertTextBefore(equalToken, " ");
}
});
}
if (!spacedAfter) {
context.report({
node: attrNode,
messageId: "needSpaceAfter",
loc: equalToken.loc.start,
fix(fixer) {
return fixer.insertTextAfter(equalToken, " ");
}
});
}
}
});
}
};
}
});
module.exports = jsxEqualsSpacing;