refactor: remove duplicate import in examples
[poolifier.git] / .eslintrc.js
index e35a48df6bc3e96fbcf3ebfb247e53ae875ad030..e2fc35b2c1264d4c08e5af3de0a3cc3fb36d924b 100644 (file)
-// @ts-check
 const { defineConfig } = require('eslint-define-config')
 
 module.exports = defineConfig({
+  root: true,
   env: {
-    es2021: true,
+    es2022: true,
     node: true,
     mocha: true
   },
-  parser: '@typescript-eslint/parser',
   parserOptions: {
-    ecmaVersion: 2020,
-    sourceType: 'module',
-    warnOnUnsupportedTypeScriptVersion: false
+    ecmaVersion: 2022,
+    sourceType: 'module'
   },
-  plugins: [
-    '@typescript-eslint',
-    'promise',
-    'prettierx',
-    'jsdoc',
-    'spellcheck'
-  ],
+  plugins: ['promise', '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:import/recommended',
+    'plugin:promise/recommended'
   ],
+  settings: {
+    'import/resolver': {
+      typescript: {
+        project: './tsconfig.eslint.json'
+      }
+    }
+  },
   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',
+      'error',
       {
-        ignoreMemberSort: true,
         ignoreDeclarationSort: true
       }
     ],
+    'import/order': 'error',
 
     'spellcheck/spell-checker': [
       'warn',
       {
         skipWords: [
+          'axios',
+          'benoit',
+          'benny',
+          'browserslist',
+          'builtins',
           'christopher',
+          'cjs',
+          'cloneable',
           'comparator',
+          'cpu',
+          'cpus',
+          'ctx',
+          'deprecations',
+          'dequeue',
+          'dequeued',
           'ecma',
+          'elu',
+          'enqueue',
           'enum',
-          'inheritdoc',
+          'errored',
+          'esm',
+          'fastify',
+          'fibonacci',
+          'fp',
+          'fs',
+          'inheritDoc',
+          'javascript',
           'jsdoc',
-          'pioardi',
+          'localhost',
+          'microjob',
+          'mjs',
+          'npx',
+          'num',
+          'os',
+          'perf',
+          'piscina',
+          'pnpm',
           'poolifier',
+          'poolify',
+          'readdir',
           'readonly',
-          'serializable',
+          'req',
+          'resize',
+          'sinon',
+          'threadjs',
+          'threadwork',
+          'tinypool',
+          'tsconfig',
+          'tsdoc',
+          'typedoc',
+          'unlink',
+          'unref',
           'unregister',
-          'workerpool'
+          'utf8',
+          'workerpool',
+          'ws',
+          'wss',
+          'wwr'
         ],
         skipIfMatch: ['^@.*', '^plugin:.*']
       }
@@ -72,70 +102,82 @@ module.exports = defineConfig({
   },
   overrides: [
     {
-      files: ['src/**/*.ts'],
-      extends: 'plugin:jsdoc/recommended',
+      files: ['**/*.ts'],
+      plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'],
+      parser: '@typescript-eslint/parser',
+      parserOptions: {
+        project: './tsconfig.eslint.json'
+      },
+      extends: [
+        'plugin:@typescript-eslint/recommended',
+        'plugin:@typescript-eslint/recommended-requiring-type-checking',
+        'plugin:import/typescript',
+        'standard-with-typescript'
+      ],
       rules: {
-        '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
-            }
-          }
+        '@typescript-eslint/no-inferrable-types': [
+          'error',
+          { ignoreProperties: 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'
+        'tsdoc/syntax': 'warn'
       }
     },
     {
-      files: ['*.js'],
-      extends: 'plugin:node/recommended',
+      files: ['examples/typescript/**/*.ts'],
       rules: {
-        '@typescript-eslint/no-unused-vars': 'off',
-        '@typescript-eslint/no-var-requires': 'off'
+        'import/no-unresolved': 'off',
+        '@typescript-eslint/no-unsafe-argument': 'off',
+        '@typescript-eslint/no-unsafe-call': 'off',
+        '@typescript-eslint/no-unsafe-return': 'off',
+        '@typescript-eslint/no-unsafe-assignment': 'off',
+        '@typescript-eslint/no-unsafe-member-access': 'off',
+        '@typescript-eslint/no-unnecessary-type-assertion': 'off',
+        '@typescript-eslint/strict-boolean-expressions': 'off',
+        '@typescript-eslint/return-await': 'off'
       }
     },
     {
-      files: ['examples/typescript/**/*.ts'],
+      files: ['**/*.js', '**/*.mjs'],
+      plugins: ['jsdoc'],
+      extends: ['plugin:n/recommended', 'plugin:jsdoc/recommended', 'standard']
+    },
+    {
+      files: ['tests/**/*.js'],
       rules: {
+        'jsdoc/require-jsdoc': 'off'
+      }
+    },
+    {
+      files: ['tests/pools/selection-strategies/**/*.js'],
+      rules: {
+        'n/no-missing-require': 'off'
+      }
+    },
+    {
+      files: ['benchmarks/**/*.js', 'benchmarks/**/*.mjs'],
+      rules: {
+        'jsdoc/require-jsdoc': 'off'
+      }
+    },
+    {
+      files: ['benchmarks/versus-external-pools/**/*.js'],
+      rules: {
+        'n/no-missing-require': 'off'
+      }
+    },
+    {
+      files: ['benchmarks/versus-external-pools/**/*.mjs'],
+      rules: {
+        'n/no-missing-import': 'off',
         'import/no-unresolved': 'off'
       }
     },
     {
-      files: ['examples/**/*.js'],
+      files: ['examples/javascript/**/*.js'],
       rules: {
-        'node/no-missing-require': 'off'
+        'n/no-missing-require': 'off',
+        'jsdoc/require-jsdoc': 'off'
       }
     }
-  ],
-  settings: {
-    jsdoc: {
-      mode: 'typescript'
-    }
-  }
+  ]
 })