Skip to content

Commit

Permalink
Additional fix for include extensions
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Nov 11, 2024
1 parent 7ed6553 commit 1d9a839
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion language/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 22 additions & 0 deletions tests/suite/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 1d9a839

Please sign in to comment.