Open tjx666 opened 4 months ago
You can do this through the plugin API.
import { Plugin, defineConfig } from '@tsslint/config';
export default defineConfig({
plugins: [
createIngorePlugin(/\/\/ tsslint-disable-next-line\n/g),
createIngorePlugin(/\/\/ eslint-disable-next-line\n/g),
]
});
function createIngorePlugin(pattern: RegExp): Plugin {
return ({ languageService }) => ({
resolveDiagnostics(fileName, results) {
const sourceFile = languageService.getProgram()?.getSourceFile(fileName);
if (!sourceFile) {
return results;
}
const comments = [...sourceFile.text.matchAll(pattern)];
const lines = new Set(comments.map(comment => sourceFile.getLineAndCharacterOfPosition(comment.index).line));
return results.filter(error => error.source !== 'tsslint' || !lines.has(sourceFile.getLineAndCharacterOfPosition(error.start).line - 1));
},
});
}
@johnsoncodehk works fine, but I think this should be builtin feature.
This is not yet a built-in feature, as projects migrating from ESLint may still need to support eslint-disable-next-line
instead of tsslint-disable-next-line
/@tsslint-ignore
, so this syntax needs to be available configuration.
I will keep this issue open.
like eslint, we can disable by: