diff --git a/.README/processors.md b/.README/processors.md index 04600b62f..39d7e754e 100644 --- a/.README/processors.md +++ b/.README/processors.md @@ -97,7 +97,7 @@ For defaults, a couple rules are enabled which are usually useful: ```js import {getJsdocProcessorPlugin} from 'eslint-plugin-jsdoc'; -import { +import ts, { parser as typescriptEslintParser, } from 'typescript-eslint'; @@ -129,8 +129,10 @@ export default [ }, processor: 'examples/examples' }, + // Apply your TypeScript config + ...ts.configs.recommended, { - // Target the blocks within TypeScript + // Target the @example blocks within TypeScript files: [ // `**/*.ts` could also work if you want to share this config // with other non-@example TypeScript @@ -144,8 +146,13 @@ export default [ rules: { // Add the rules you want to apply to @example here 'no-extra-semi': 'error', + // disable problematic rules here, e.g., // ...jsdoc.configs.examples[1].rules + + // Due to https://github.com/gajus/eslint-plugin-jsdoc/issues/1377 , + // `typescript-eslint` type-checked rules must currently be disbaled + ...ts.configs.disableTypeChecked.rules } } ]; diff --git a/.README/rules/check-examples.md b/.README/rules/check-examples.md index ed00b4551..e2afb2ec8 100644 --- a/.README/rules/check-examples.md +++ b/.README/rules/check-examples.md @@ -146,7 +146,7 @@ by decreasing precedence: use extra lines within examples just for easier illustration purposes. * `no-undef` - Many variables in examples will be `undefined`. -* `no-unused-vars` - It is common to define variables for clarity without +* `no-unused-vars` (and `@typescript-eslint/no-unused-vars`) - It is common to define variables for clarity without always using them within examples. * `padded-blocks` (and `@stylistic/padded-blocks`) - It can generally look nicer to pad a little even if one's code follows more stringency as far diff --git a/docs/processors.md b/docs/processors.md index 4c87e3c21..1744b1c2e 100644 --- a/docs/processors.md +++ b/docs/processors.md @@ -101,7 +101,7 @@ For defaults, a couple rules are enabled which are usually useful: ```js import {getJsdocProcessorPlugin} from 'eslint-plugin-jsdoc'; -import { +import ts, { parser as typescriptEslintParser, } from 'typescript-eslint'; @@ -133,8 +133,10 @@ export default [ }, processor: 'examples/examples' }, + // Apply your TypeScript config + ...ts.configs.recommended, { - // Target the blocks within TypeScript + // Target the @example blocks within TypeScript files: [ // `**/*.ts` could also work if you want to share this config // with other non-@example TypeScript @@ -148,8 +150,13 @@ export default [ rules: { // Add the rules you want to apply to @example here 'no-extra-semi': 'error', + // disable problematic rules here, e.g., // ...jsdoc.configs.examples[1].rules + + // Due to https://github.com/gajus/eslint-plugin-jsdoc/issues/1377 , + // `typescript-eslint` type-checked rules must currently be disbaled + ...ts.configs.disableTypeChecked.rules } } ]; diff --git a/docs/rules/check-examples.md b/docs/rules/check-examples.md index 37b96d900..db16a19be 100644 --- a/docs/rules/check-examples.md +++ b/docs/rules/check-examples.md @@ -173,7 +173,7 @@ by decreasing precedence: use extra lines within examples just for easier illustration purposes. * `no-undef` - Many variables in examples will be `undefined`. -* `no-unused-vars` - It is common to define variables for clarity without +* `no-unused-vars` (and `@typescript-eslint/no-unused-vars`) - It is common to define variables for clarity without always using them within examples. * `padded-blocks` (and `@stylistic/padded-blocks`) - It can generally look nicer to pad a little even if one's code follows more stringency as far diff --git a/src/index-cjs.js b/src/index-cjs.js index 387809933..fa253093f 100644 --- a/src/index-cjs.js +++ b/src/index-cjs.js @@ -563,6 +563,8 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([ // Can generally look nicer to pad a little even if code imposes more stringency '@stylistic/padded-blocks': 0, + '@typescript-eslint/no-unused-vars': 0, + // "always" newline rule at end unlikely in sample code 'eol-last': 0, diff --git a/src/index.js b/src/index.js index aa693a563..796968c7f 100644 --- a/src/index.js +++ b/src/index.js @@ -569,6 +569,8 @@ index.configs.examples = /** @type {import('eslint').Linter.Config[]} */ ([ // Can generally look nicer to pad a little even if code imposes more stringency '@stylistic/padded-blocks': 0, + '@typescript-eslint/no-unused-vars': 0, + // "always" newline rule at end unlikely in sample code 'eol-last': 0, diff --git a/src/rules/checkExamples.js b/src/rules/checkExamples.js index 54d980180..1d0c73352 100644 --- a/src/rules/checkExamples.js +++ b/src/rules/checkExamples.js @@ -47,6 +47,8 @@ const defaultMdRules = { // Can generally look nicer to pad a little even if code imposes more stringency '@stylistic/padded-blocks': 0, + '@typescript-eslint/no-unused-vars': 0, + // "always" newline rule at end unlikely in sample code 'eol-last': 0,