X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=.eslintrc.js;h=8e43f37eb12b5751a4c1231dfe762d09818b2070;hb=90a9a10f90101fa6ad60683f4ce75bb422c8652d;hp=8f902bd228e5b3a81ede40194c699f73ef121b66;hpb=fa699c4287a0a4940862e452109dddc7be53403b;p=poolifier.git diff --git a/.eslintrc.js b/.eslintrc.js index 8f902bd2..8e43f37e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,7 @@ -module.exports = { +// @ts-check +const { defineConfig } = require('eslint-define-config') + +module.exports = defineConfig({ env: { es2021: true, node: true, @@ -7,54 +10,130 @@ module.exports = { parser: '@typescript-eslint/parser', parserOptions: { ecmaVersion: 2020, - sourceType: 'module' + sourceType: 'module', + warnOnUnsupportedTypeScriptVersion: false }, - plugins: ['@typescript-eslint', 'prettierx'], + plugins: [ + '@typescript-eslint', + 'promise', + 'prettierx', + 'jsdoc', + 'spellcheck' + ], extends: [ 'standard', 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', 'plugin:import/errors', 'plugin:import/warnings', - 'plugin:import/typescript', - 'plugin:prettierx/standardx', - 'plugin:prettierx/@typescript-eslint', - 'prettier', - 'prettier/standard', - 'prettier/@typescript-eslint' + 'plugin:promise/recommended', + 'plugin:prettierx/standardx' ], rules: { 'no-void': 'off', - // We have some intentionally empty functions - '@typescript-eslint/no-empty-function': 'off', - - '@typescript-eslint/no-inferrable-types': [ - 'error', - { ignoreProperties: true } - ], - 'sort-imports': [ 'warn', { ignoreMemberSort: true, - memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple'] + ignoreDeclarationSort: true + } + ], + + 'spellcheck/spell-checker': [ + 'warn', + { + skipWords: [ + 'christopher', + 'comparator', + 'ecma', + 'enum', + 'inheritdoc', + 'jsdoc', + 'poolifier', + 'readonly', + 'serializable', + 'unregister', + 'workerpool' + ], + skipIfMatch: ['^@.*', '^plugin:.*'] } ] }, overrides: [ { - files: ['*.js'], + files: ['**/*.ts'], + extends: [ + 'plugin:jsdoc/recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:import/typescript' + ], rules: { - '@typescript-eslint/no-unused-vars': 'off', - '@typescript-eslint/no-var-requires': 'off' + // We have some intentionally empty functions + '@typescript-eslint/no-empty-function': 'off', + + '@typescript-eslint/no-inferrable-types': [ + 'error', + { ignoreProperties: true } + ], + + 'no-useless-constructor': 'off', + + 'jsdoc/match-description': [ + 'warn', + { + // mainDescription: + // '/^[A-Z`].+?(\\.|:)(\\n\\n.*((\\n{1,2}- .+)|(_.+_)|`.+`|\\n\\n---))?$/us', + // matchDescription: '^[A-Z`].+(\\.|`.+`)$', + contexts: ['any'], + tags: { + param: true, + returns: true + } + } + ], + 'jsdoc/no-types': 'error', + 'jsdoc/require-jsdoc': [ + 'warn', + { + contexts: [ + 'ClassDeclaration', + 'ClassProperty:not([accessibility=/(private|protected)/])', + 'ExportNamedDeclaration:has(VariableDeclaration)', + 'FunctionExpression', + 'MethodDefinition:not([accessibility=/(private|protected)/]) > FunctionExpression', + 'TSEnumDeclaration', + 'TSInterfaceDeclaration', + 'TSMethodSignature', + // 'TSPropertySignature', + 'TSTypeAliasDeclaration' + ] + } + ], + 'jsdoc/require-param-type': 'off', + 'jsdoc/require-returns-type': 'off' + } + }, + { + files: ['**/*.js'], + extends: 'plugin:node/recommended' + }, + { + files: ['examples/typescript/**/*.ts'], + rules: { + 'import/no-unresolved': 'off', + 'jsdoc/require-jsdoc': 'off' } }, { - files: ['examples/typescript/*.ts'], + files: ['examples/**/*.js'], rules: { - 'import/no-unresolved': 'off' + 'node/no-missing-require': 'off' } } - ] -} + ], + settings: { + jsdoc: { + mode: 'typescript' + } + } +})