ifc-language-server/node_modules/@stylistic/eslint-plugin/dist/rules/linebreak-style.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

71 lines
1.9 KiB
JavaScript

'use strict';
var utils = require('../utils.js');
require('eslint-visitor-keys');
require('espree');
require('estraverse');
var linebreakStyle = utils.createRule({
name: "linebreak-style",
package: "js",
meta: {
type: "layout",
docs: {
description: "Enforce consistent linebreak style"
},
fixable: "whitespace",
schema: [
{
type: "string",
enum: ["unix", "windows"]
}
],
messages: {
expectedLF: "Expected linebreaks to be 'LF' but found 'CRLF'.",
expectedCRLF: "Expected linebreaks to be 'CRLF' but found 'LF'."
}
},
create(context) {
const sourceCode = context.sourceCode;
function createFix(range, text) {
return function(fixer) {
return fixer.replaceTextRange(range, text);
};
}
return {
Program: function checkForLinebreakStyle(node) {
const linebreakStyle = context.options[0] || "unix";
const expectedLF = linebreakStyle === "unix";
const expectedLFChars = expectedLF ? "\n" : "\r\n";
const source = sourceCode.getText();
const pattern = utils.createGlobalLinebreakMatcher();
let match;
let i = 0;
while ((match = pattern.exec(source)) !== null) {
i++;
if (match[0] === expectedLFChars)
continue;
const index = match.index;
const range = [index, index + match[0].length];
context.report({
node,
loc: {
start: {
line: i,
column: sourceCode.lines[i - 1].length
},
end: {
line: i + 1,
column: 0
}
},
messageId: expectedLF ? "expectedLF" : "expectedCRLF",
fix: createFix(range, expectedLFChars)
});
}
}
};
}
});
module.exports = linebreakStyle;