Skip to content

Commit

Permalink
patch tsdoc/syntax (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
taichunmin authored Jun 13, 2024
2 parents 78880a4 + 306b385 commit a99f5cd
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 86 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
},
extends: ['love'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'],
plugins: ['@typescript-eslint', 'eslint-plugin-local-rules'],
parserOptions: {
project: true,
},
Expand All @@ -17,10 +17,10 @@ module.exports = {
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/unbound-method': 'off',
'local-rules/tsdoc/syntax': 'warn',
'multiline-ternary': 'off',
'no-extra-boolean-cast': 'off',
'no-return-await': 'off',
'tsdoc/syntax': 'warn',
'@typescript-eslint/no-invalid-void-type': ['error', {
allowAsThisParameter: true,
}],
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ out
/.gitattributes
/.github
/.rollup.cache
/*.cjs
/*.ts
/dist/assets
/jest.config.cjs
Expand Down
29 changes: 29 additions & 0 deletions eslint-local-rules.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// https://github.com/microsoft/tsdoc/issues/220#issuecomment-1629947425
// eslint-disable-file
const _ = require('lodash')
const eslintPluginTsdoc = require('eslint-plugin-tsdoc')
const fs = require('fs')

fs.writeFileSync('./debug.txt', 'test\r\n', { flag: 'as' })

function eslintPluginTsdocPatch () {
const origRule = eslintPluginTsdoc.rules.syntax
return {
...origRule,
create: context => {
const patched = {
report: opts => {
// fs.writeFileSync('./debug.txt', `${JSON.stringify(opts)}\r\n`, { flag: 'as' })
if (opts.messageId === 'tsdoc-param-tag-with-invalid-name' && opts?.data?.unformattedText?.indexOf?.('non-word characters') !== -1) return
return context.report(opts)
},
}
Object.setPrototypeOf(patched, context)
return origRule.create(patched)
},
}
}

module.exports = {
'tsdoc/syntax': eslintPluginTsdocPatch(),
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"eslint-config-love": "^43",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-local-rules": "^2.0.1",
"eslint-plugin-n": "^17.7.0",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-pug": "^1.2.5",
Expand Down
Loading

0 comments on commit a99f5cd

Please sign in to comment.