X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=.eslintrc.js;h=f9453f90f5dd8825e45180a5f8b61004689ff444;hb=435bc05ac96bd7029dc90568a78560f96185b4cf;hp=6c710303838f3cfbcbb05084ea11b739872fbe61;hpb=50aa790189f6423c52ea72198380dbe93c025e40;p=poolifier.git diff --git a/.eslintrc.js b/.eslintrc.js index 6c710303..f9453f90 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,60 +1,155 @@ -module.exports = { +// @ts-check +const { defineConfig } = require('eslint-define-config') + +module.exports = defineConfig({ env: { es2021: true, node: true, mocha: true }, - parser: '@typescript-eslint/parser', parserOptions: { - ecmaVersion: 2020, + ecmaVersion: 2021, sourceType: 'module' }, - plugins: ['@typescript-eslint', 'prettierx'], + plugins: ['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:import/recommended', + 'plugin:jsdoc/recommended', + '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, ignoreDeclarationSort: true } + ], + + 'spellcheck/spell-checker': [ + 'warn', + { + skipWords: [ + 'browserslist', + 'christopher', + 'comparator', + 'cpu', + 'cpus', + 'ecma', + 'enum', + 'fibonacci', + 'inheritDoc', + 'jsdoc', + 'num', + 'os', + 'poolifier', + 'readonly', + 'serializable', + 'sinon', + 'tsconfig', + 'typedoc', + 'unregister', + 'workerpool' + ], + skipIfMatch: ['^@.*', '^plugin:.*'] + } ] }, overrides: [ { - files: ['*.js'], + files: ['**/*.ts'], + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.json' + }, + plugins: ['@typescript-eslint'], + extends: [ + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'plugin:import/typescript' + ], + rules: { + // 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', + { + 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: ['tests/**/*.js'], + rules: { + 'jsdoc/require-jsdoc': 'off' + } + }, + { + files: ['tests/pools/selection-strategies/**/*.js'], rules: { - '@typescript-eslint/no-unused-vars': 'off', - '@typescript-eslint/no-var-requires': 'off' + 'node/no-missing-require': 'off' } }, { - files: ['examples/typescript/*.ts'], + files: ['benchmarks/**/*.js'], rules: { - 'import/no-unresolved': 'off' + 'jsdoc/require-jsdoc': 'off' } + }, + { + files: ['examples/**/*.js'], + rules: { + 'node/no-missing-require': 'off', + 'jsdoc/require-jsdoc': 'off' + } + } + ], + settings: { + jsdoc: { + mode: 'typescript' } - ] -} + } +})