From 72924f0a5fdd8f5ac1f6322e79f9fa0bd49d7090 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Sun, 10 Nov 2024 16:33:05 -0500 Subject: [PATCH] Improvement to linter to not run certain rules for includes Signed-off-by: worksofliam --- language/linter.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/language/linter.ts b/language/linter.ts index 62551f39..379e689c 100644 --- a/language/linter.ts +++ b/language/linter.ts @@ -9,6 +9,9 @@ import Document from "./document"; import { IssueRange, Offset, Rules, SelectBlock } from "./parserTypes"; import Declaration from "./models/declaration"; +const BANNED_FROM_INCLUDES = [`NoUnreferenced`]; +const INCLUDE_EXTENSIONS = [`rpgleinc`, `rpgleh`]; + const errorText = { 'BlankStructNamesCheck': `Struct names cannot be blank (\`*N\`).`, 'QualifiedCheck': `Struct names must be qualified (\`QUALIFIED\`).`, @@ -60,6 +63,14 @@ export default class Linter { const indentEnabled = rules.indent !== undefined; const indent = rules.indent || 2; + const uriExtension = data.uri.split('.').pop().toLowerCase(); + + if (INCLUDE_EXTENSIONS.includes(uriExtension)) { + for (const banned of BANNED_FROM_INCLUDES) { + rules[banned] = false; + } + } + // Excluding indent const ruleCount = Object.keys(rules).length - (rules.indent ? 1 : 0);