diff --git a/src/language/linter.js b/src/language/linter.js index 3fe8830c..5c47d909 100644 --- a/src/language/linter.js +++ b/src/language/linter.js @@ -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( @@ -188,6 +188,11 @@ module.exports = class Linter { } else { skipIndentCheck = true; } + + // Special comment check + if (comment.trim() === `@rpglint-skip`) { + break; + } } if (!isLineComment) { diff --git a/tests/suite/index.js b/tests/suite/index.js index 80e67ce7..c7b90107 100644 --- a/tests/suite/index.js +++ b/tests/suite/index.js @@ -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 = [ ``,