Use JsDoc default regexp
[poolifier.git] / .eslintrc.js
index 738e7df94c87ec612a42acc67b43dff4fbd6a048..8e43f37eb12b5751a4c1231dfe762d09818b2070 100644 (file)
@@ -1,4 +1,7 @@
-module.exports = {
+// @ts-check
+const { defineConfig } = require('eslint-define-config')
+
+module.exports = defineConfig({
   env: {
     es2021: true,
     node: true,
@@ -7,61 +10,118 @@ module.exports = {
   parser: '@typescript-eslint/parser',
   parserOptions: {
     ecmaVersion: 2020,
-    sourceType: 'module'
+    sourceType: 'module',
+    warnOnUnsupportedTypeScriptVersion: false
   },
-  plugins: ['@typescript-eslint', 'promise', 'prettierx', 'jsdoc'],
+  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:promise/recommended',
-    'plugin:prettierx/standardx',
-    'plugin:prettierx/@typescript-eslint'
+    '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: [
+          'christopher',
+          'comparator',
+          'ecma',
+          'enum',
+          'inheritdoc',
+          'jsdoc',
+          'poolifier',
+          'readonly',
+          'serializable',
+          'unregister',
+          'workerpool'
+        ],
+        skipIfMatch: ['^@.*', '^plugin:.*']
+      }
     ]
   },
   overrides: [
     {
-      files: ['src/**/*.ts'],
-      extends: 'plugin:jsdoc/recommended',
+      files: ['**/*.ts'],
+      extends: [
+        'plugin:jsdoc/recommended',
+        'plugin:@typescript-eslint/recommended',
+        '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',
+          {
+            // 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',
-      rules: {
-        '@typescript-eslint/no-unused-vars': 'off',
-        '@typescript-eslint/no-var-requires': 'off'
-      }
+      files: ['**/*.js'],
+      extends: 'plugin:node/recommended'
     },
     {
       files: ['examples/typescript/**/*.ts'],
       rules: {
-        'import/no-unresolved': 'off'
+        'import/no-unresolved': 'off',
+        'jsdoc/require-jsdoc': 'off'
       }
     },
     {
@@ -70,5 +130,10 @@ module.exports = {
         'node/no-missing-require': 'off'
       }
     }
-  ]
-}
+  ],
+  settings: {
+    jsdoc: {
+      mode: 'typescript'
+    }
+  }
+})