Repository: karen-irc/option-t
Pull request #1410 (2022-08-30 19:15:27)

Prepare to migrate to new eslint config


Patch:
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 21fc7275..7e0aba74 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -2,6 +2,31 @@
 
 'use strict';
 
+const path = require('node:path');
+
+const { rules } = require('./tools/eslint/eslintrc_typescript.cjs');
+const KEY_NAMING_CONVENTION = '@typescript-eslint/naming-convention';
+
+// We allow `K` or `V` forms to avoid to rewrite type parameters.
+const newNamingConventionRule = [...rules[KEY_NAMING_CONVENTION]].map((item) => {
+    if (typeof item === 'string') {
+        return item;
+    }
+
+    if (item.selector !== 'typeParameter') {
+        return item;
+    }
+
+    return {
+        'selector': 'typeParameter',
+        'format': ['PascalCase'],
+        'custom': {
+            'regex': '(^[A-Z]\\d?$|^T[A-Z][a-zA-Z]+\\d?$)',
+            'match': true,
+        },
+    };
+});
+
 // ESLint Configuration Files enables to include comments.
 // https://eslint.org/docs/user-guide/configuring/
 module.exports = {
@@ -38,13 +63,39 @@ module.exports = {
             },
         },
         {
-            'files': ['*.mjs'],
+            'files': ['*.js', '*.mjs'],
+            'parserOptions': {
+                'sourceType': 'module',
+            },
+
+            'rules': {
+            },
+        },
+        {
+            'files': ['./src/**/*'],
+            'extends': ['./tools/eslint/eslintrc_typescript.cjs', 'prettier'],
+
             'parserOptions': {
                 'sourceType': 'module',
+                'project': path.resolve(__dirname, './tsconfig.eslint.json'),
+                'extraFileExtensions': ['.cjs'],
+            },
+
+            'env': {
+                'es6': false,
+                'node': false,
+                'commonjs': false,
             },
 
             'rules': {
+                [KEY_NAMING_CONVENTION]: newNamingConventionRule,
             },
         },
+        {
+            'files': ['./__tests__/**/*'],
+            'rules': {
+                'no-magic-numbers': 'off',
+            },
+        }
     ],
 };
diff --git a/src/.eslintrc.cjs b/src/.eslintrc.cjs
deleted file mode 100644
index 23c8c5d3..00000000
--- a/src/.eslintrc.cjs
+++ /dev/null
@@ -1,52 +0,0 @@
-/* eslint-env node */
-
-'use strict'; // eslint-disable-line strict
-
-// eslint-disable-next-line @typescript-eslint/no-require-imports
-const path = require('path');
-
-// eslint-disable-next-line @typescript-eslint/no-require-imports
-const { rules } = require('../tools/eslint/eslintrc_typescript.cjs');
-const KEY_NAMING_CONVENTION = '@typescript-eslint/naming-convention';
-
-// We allow `K` or `V` forms to avoid to rewrite type parameters.
-const newNamingConventionRule = [...rules[KEY_NAMING_CONVENTION]].map((item) => {
-    if (typeof item === 'string') {
-        return item;
-    }
-
-    if (item.selector !== 'typeParameter') {
-        return item;
-    }
-
-    return {
-        selector: 'typeParameter',
-        format: ['PascalCase'],
-        custom: {
-            regex: '(^[A-Z]\\d?$|^T[A-Z][a-zA-Z]+\\d?$)',
-            match: true,
-        },
-    };
-});
-
-// ESLint Configuration Files enables to include comments.
-// https://eslint.org/docs/user-guide/configuring/
-module.exports = {
-    extends: ['../tools/eslint/eslintrc_typescript.cjs', 'prettier'],
-
-    parserOptions: {
-        sourceType: 'module',
-        project: path.resolve(__dirname, '../tsconfig.eslint.json'),
-        extraFileExtensions: ['.cjs'],
-    },
-
-    env: {
-        es6: false,
-        node: false,
-        commonjs: false,
-    },
-
-    rules: {
-        [KEY_NAMING_CONVENTION]: newNamingConventionRule,
-    },
-};


Test patch:
diff --git a/__tests__/.eslintrc.cjs b/__tests__/.eslintrc.cjs
deleted file mode 100644
index 96461bf3..00000000
--- a/__tests__/.eslintrc.cjs
+++ /dev/null
@@ -1,38 +0,0 @@
-/* eslint-env node */
-
-'use strict';
-
-const path = require('path');
-
-// ESLint Configuration Files enables to include comments.
-// https://eslint.org/docs/user-guide/configuring/
-module.exports = {
-    extends: ['prettier'],
-
-    env: {
-        es6: true,
-        node: false,
-        commonjs: false,
-    },
-
-    rules: {
-        'no-magic-numbers': 'off',
-    },
-
-    overrides: [
-        {
-            files: ['*.ts'],
-
-            extends: ['../tools/eslint/eslintrc_typescript.cjs', 'prettier'],
-
-            parserOptions: {
-                sourceType: 'module',
-                project: path.resolve(__dirname, '../tsconfig.eslint.json'),
-            },
-
-            rules: {
-                '@typescript-eslint/no-magic-numbers': 'off',
-            },
-        },
-    ],
-};