Skip to content

Commit

Permalink
rpglint-skip directive
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Feb 3, 2022
1 parent 2bdbbc7 commit 0297514
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/language/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ module.exports = class Linter {
}

if (isLineComment) {
const comment = line.substring(currentIndent + 2).trimEnd();
if (rules.PrettyComments) {
const comment = line.substring(currentIndent + 2).trimEnd();
if (comment === ``) {
errors.push({
range: new vscode.Range(
Expand Down Expand Up @@ -188,6 +188,11 @@ module.exports = class Linter {
} else {
skipIndentCheck = true;
}

// Special comment check
if (comment.trim() === `@rpglint-skip`) {
break;
}
}

if (!isLineComment) {
Expand Down
43 changes: 43 additions & 0 deletions tests/suite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,49 @@ module.exports = {
assert.strictEqual(indentErrors.length, 0, `Expect length of 0`);
},

skip1: async () => {
const lines = [
`**free`,
``,
`/copy myds.ds`,
`end-ds;`,
``,
`dsply thingy;`,
``,
`return`,
].join(`\n`);

const parser = new Parser();
const cache = await parser.getDocs(URI, lines);
const { indentErrors } = Linter.getErrors(lines, {
indent: 2
}, cache);

assert.strictEqual(indentErrors.length > 0, true, `Expect indent errors`);
},

skip2: async () => {
const lines = [
`**free`,
``,
`/copy myds.ds`,
`// @rpglint-skip`,
`end-ds;`,
``,
`dsply thingy;`,
``,
`return`,
].join(`\n`);

const parser = new Parser();
const cache = await parser.getDocs(URI, lines);
const { indentErrors } = Linter.getErrors(lines, {
indent: 2
}, cache);

assert.strictEqual(indentErrors.length, 0, `Expect no indent errors`);
},

fixed1: async () => {
const lines = [
``,
Expand Down

0 comments on commit 0297514

Please sign in to comment.