Skip to content

Commit 1d9a839

Browse files
committed
Additional fix for include extensions
Signed-off-by: worksofliam <[email protected]>
1 parent 7ed6553 commit 1d9a839

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

language/linter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ export default class Linter {
6363
const indentEnabled = rules.indent !== undefined;
6464
const indent = rules.indent || 2;
6565

66-
const uriExtension = data.uri.split('.').pop().toLowerCase();
66+
let uriExtension = data.uri.split('.').pop().toLowerCase();
67+
if (uriExtension.includes(`?`)) {
68+
uriExtension = uriExtension.split(`?`)[0];
69+
}
6770

6871
if (INCLUDE_EXTENSIONS.includes(uriExtension)) {
6972
for (const banned of BANNED_FROM_INCLUDES) {

tests/suite/linter.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { test, expect } from "vitest";
77
const parser = setupParser();
88
const uri = `source.rpgle`;
99
const includeUri = `source.rpgleinc`;
10+
const memberIncludeUri = `/LIB/SRC/MEMBER.RPGLEINC?readonly`;
1011

1112
test("linter_indent_multi_1", async () => {
1213
const lines = [
@@ -3418,6 +3419,27 @@ test('Linter running on rpgleinc', async () => {
34183419
SpecificCasing: [{operation: "dcl-s", expected: `DCL-S`}]
34193420
}, cache);
34203421

3422+
expect(errors.length).toBe(1);
3423+
expect(errors[0]).toMatchObject({
3424+
offset: { position: 7, end: 12 },
3425+
type: 'SpecificCasing',
3426+
newValue: 'DCL-S'
3427+
});
3428+
});
3429+
3430+
test('Linter running on member rpgleinc', async () => {
3431+
const lines = [
3432+
`**free`,
3433+
`Dcl-S CustomerName_t varchar(40) template;`,
3434+
].join(`\n`);
3435+
3436+
const cache = await parser.getDocs(memberIncludeUri, lines, { ignoreCache: true, withIncludes: true });
3437+
const { errors } = Linter.getErrors({ uri: memberIncludeUri, content: lines }, {
3438+
IncorrectVariableCase: true,
3439+
NoUnreferenced: true,
3440+
SpecificCasing: [{operation: "dcl-s", expected: `DCL-S`}]
3441+
}, cache);
3442+
34213443
expect(errors.length).toBe(1);
34223444
expect(errors[0]).toMatchObject({
34233445
offset: { position: 7, end: 12 },

0 commit comments

Comments
 (0)