-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] support disable comment #12
Labels
enhancement
New feature or request
Comments
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
added a commit
that referenced
this issue
Jun 15, 2024
@johnsoncodehk works fine, but I think this should be builtin feature. |
johnsoncodehk
added a commit
that referenced
this issue
Jun 15, 2024
This is not yet a built-in feature, as projects migrating from ESLint may still need to support I will keep this issue open. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
like eslint, we can disable by:
The text was updated successfully, but these errors were encountered: