- 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."
66 lines
2.2 KiB
JavaScript
66 lines
2.2 KiB
JavaScript
'use strict';
|
|
|
|
var utils = require('../utils.js');
|
|
require('eslint-visitor-keys');
|
|
require('espree');
|
|
require('estraverse');
|
|
|
|
const messages = {
|
|
propOnNewLine: "Property should be placed on a new line",
|
|
propOnSameLine: "Property should be placed on the same line as the component declaration"
|
|
};
|
|
var jsxFirstPropNewLine = utils.createRule({
|
|
name: "jsx-first-prop-new-line",
|
|
package: "jsx",
|
|
meta: {
|
|
type: "layout",
|
|
docs: {
|
|
description: "Enforce proper position of the first property in JSX"
|
|
},
|
|
fixable: "code",
|
|
messages,
|
|
schema: [
|
|
{
|
|
type: "string",
|
|
enum: ["always", "never", "multiline", "multiline-multiprop", "multiprop"]
|
|
}
|
|
]
|
|
},
|
|
create(context) {
|
|
const configuration = context.options[0] || "multiline-multiprop";
|
|
function isMultilineJSX(jsxNode) {
|
|
return jsxNode.loc.start.line < jsxNode.loc.end.line;
|
|
}
|
|
return {
|
|
JSXOpeningElement(node) {
|
|
if (configuration === "multiline" && isMultilineJSX(node) || configuration === "multiline-multiprop" && isMultilineJSX(node) && node.attributes.length > 1 || configuration === "multiprop" && node.attributes.length > 1 || configuration === "always") {
|
|
node.attributes.some((decl) => {
|
|
if (decl.loc.start.line === node.loc.start.line) {
|
|
context.report({
|
|
node: decl,
|
|
messageId: "propOnNewLine",
|
|
fix(fixer) {
|
|
return fixer.replaceTextRange([(node.typeArguments || node.name).range[1], decl.range[0]], "\n");
|
|
}
|
|
});
|
|
}
|
|
return true;
|
|
});
|
|
} else if (configuration === "never" && node.attributes.length > 0 || configuration === "multiprop" && isMultilineJSX(node) && node.attributes.length <= 1) {
|
|
const firstNode = node.attributes[0];
|
|
if (node.loc.start.line < firstNode.loc.start.line) {
|
|
context.report({
|
|
node: firstNode,
|
|
messageId: "propOnSameLine",
|
|
fix(fixer) {
|
|
return fixer.replaceTextRange([node.name.range[1], firstNode.range[0]], " ");
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
module.exports = jsxFirstPropNewLine;
|