From 1d9a839912edb123219df657f3cc01ef346f2a63 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Mon, 11 Nov 2024 09:19:09 -0500 Subject: [PATCH] Additional fix for include extensions Signed-off-by: worksofliam --- language/linter.ts | 5 ++++- tests/suite/linter.test.ts | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/language/linter.ts b/language/linter.ts index 379e689c..01c4f145 100644 --- a/language/linter.ts +++ b/language/linter.ts @@ -63,7 +63,10 @@ export default class Linter { const indentEnabled = rules.indent !== undefined; const indent = rules.indent || 2; - const uriExtension = data.uri.split('.').pop().toLowerCase(); + let uriExtension = data.uri.split('.').pop().toLowerCase(); + if (uriExtension.includes(`?`)) { + uriExtension = uriExtension.split(`?`)[0]; + } if (INCLUDE_EXTENSIONS.includes(uriExtension)) { for (const banned of BANNED_FROM_INCLUDES) { diff --git a/tests/suite/linter.test.ts b/tests/suite/linter.test.ts index db1fa6f0..5fb8309b 100644 --- a/tests/suite/linter.test.ts +++ b/tests/suite/linter.test.ts @@ -7,6 +7,7 @@ import { test, expect } from "vitest"; const parser = setupParser(); const uri = `source.rpgle`; const includeUri = `source.rpgleinc`; +const memberIncludeUri = `/LIB/SRC/MEMBER.RPGLEINC?readonly`; test("linter_indent_multi_1", async () => { const lines = [ @@ -3418,6 +3419,27 @@ test('Linter running on rpgleinc', async () => { SpecificCasing: [{operation: "dcl-s", expected: `DCL-S`}] }, cache); + expect(errors.length).toBe(1); + expect(errors[0]).toMatchObject({ + offset: { position: 7, end: 12 }, + type: 'SpecificCasing', + newValue: 'DCL-S' + }); +}); + +test('Linter running on member rpgleinc', async () => { + const lines = [ + `**free`, + `Dcl-S CustomerName_t varchar(40) template;`, + ].join(`\n`); + + const cache = await parser.getDocs(memberIncludeUri, lines, { ignoreCache: true, withIncludes: true }); + const { errors } = Linter.getErrors({ uri: memberIncludeUri, content: lines }, { + IncorrectVariableCase: true, + NoUnreferenced: true, + SpecificCasing: [{operation: "dcl-s", expected: `DCL-S`}] + }, cache); + expect(errors.length).toBe(1); expect(errors[0]).toMatchObject({ offset: { position: 7, end: 12 },