- 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."
69 lines
1.7 KiB
JavaScript
69 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
var utils = require('../utils.js');
|
|
require('eslint-visitor-keys');
|
|
require('espree');
|
|
require('estraverse');
|
|
|
|
const QUOTE_SETTINGS = {
|
|
"prefer-double": {
|
|
quote: '"',
|
|
description: "singlequote",
|
|
convert(str) {
|
|
return str.replace(/'/gu, '"');
|
|
}
|
|
},
|
|
"prefer-single": {
|
|
quote: "'",
|
|
description: "doublequote",
|
|
convert(str) {
|
|
return str.replace(/"/gu, "'");
|
|
}
|
|
}
|
|
};
|
|
var jsxQuotes = utils.createRule({
|
|
name: "jsx-quotes",
|
|
package: "js",
|
|
meta: {
|
|
type: "layout",
|
|
docs: {
|
|
description: "Enforce the consistent use of either double or single quotes in JSX attributes"
|
|
},
|
|
fixable: "whitespace",
|
|
schema: [
|
|
{
|
|
type: "string",
|
|
enum: ["prefer-single", "prefer-double"]
|
|
}
|
|
],
|
|
messages: {
|
|
unexpected: "Unexpected usage of {{description}}."
|
|
}
|
|
},
|
|
create(context) {
|
|
const quoteOption = context.options[0] || "prefer-double";
|
|
const setting = QUOTE_SETTINGS[quoteOption];
|
|
function usesExpectedQuotes(node) {
|
|
return node.value.includes(setting.quote) || utils.isSurroundedBy(node.raw, setting.quote);
|
|
}
|
|
return {
|
|
JSXAttribute(node) {
|
|
const attributeValue = node.value;
|
|
if (attributeValue && utils.isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue)) {
|
|
context.report({
|
|
node: attributeValue,
|
|
messageId: "unexpected",
|
|
data: {
|
|
description: setting.description
|
|
},
|
|
fix(fixer) {
|
|
return fixer.replaceText(attributeValue, setting.convert(attributeValue.raw));
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
module.exports = jsxQuotes;
|