Skip to content

Commit

Permalink
Improvement to linter to not run certain rules for includes
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Nov 10, 2024
1 parent 62139b4 commit 72924f0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions language/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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\`).`,
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 72924f0

Please sign in to comment.