e22m4u 1 год назад
Родитель
Сommit
86873345f1
5 измененных файлов с 34 добавлено и 24 удалено
  1. 0 1
      .eslintignore
  2. 0 20
      .eslintrc.cjs
  3. 30 0
      eslint.config.js
  4. 3 1
      package.json
  5. 1 2
      src/format.js

+ 0 - 1
.eslintignore

@@ -1 +0,0 @@
-*.d.ts

+ 0 - 20
.eslintrc.cjs

@@ -1,20 +0,0 @@
-module.exports = {
-  env: {
-    es2021: true,
-    node: true
-  },
-  parserOptions: {
-    sourceType: 'module',
-    ecmaVersion: 13,
-  },
-  plugins: [
-    'mocha',
-    'chai-expect',
-  ],
-  extends: [
-    'eslint:recommended',
-    'prettier',
-    'plugin:mocha/recommended',
-    'plugin:chai-expect/recommended',
-  ],
-}

+ 30 - 0
eslint.config.js

@@ -0,0 +1,30 @@
+import js from '@eslint/js';
+import globals from 'globals';
+import mochaPlugin from 'eslint-plugin-mocha';
+import chaiExpectPlugin from 'eslint-plugin-chai-expect';
+import eslintConfigPrettier from 'eslint-config-prettier';
+
+export default [
+  {
+    languageOptions: {
+      ecmaVersion: 13,
+      sourceType: 'module',
+      globals: {
+        ...globals.node,
+        ...globals.es2021,
+        ...globals.mocha,
+      },
+    },
+    plugins: {
+      'mocha': mochaPlugin,
+      'chai-expect': chaiExpectPlugin,
+    },
+    rules: {
+      ...js.configs.recommended.rules,
+      ...eslintConfigPrettier.rules,
+      ...mochaPlugin.configs.flat.recommended.rules,
+      ...chaiExpectPlugin.configs['recommended-flat'].rules,
+    },
+    files: ['src/**/*.js'],
+  },
+];

+ 3 - 1
package.json

@@ -27,12 +27,14 @@
   "devDependencies": {
     "@commitlint/cli": "~19.3.0",
     "@commitlint/config-conventional": "~19.2.2",
+    "@eslint/js": "^9.5.0",
     "c8": "~10.1.2",
     "chai": "~5.1.1",
-    "eslint": "~8.57.0",
+    "eslint": "~9.5.0",
     "eslint-config-prettier": "~9.1.0",
     "eslint-plugin-chai-expect": "~3.1.0",
     "eslint-plugin-mocha": "~10.4.3",
+    "globals": "^15.6.0",
     "husky": "~9.0.11",
     "mocha": "~10.4.0",
     "prettier": "~3.3.2",

+ 1 - 2
src/format.js

@@ -28,7 +28,6 @@ export function format(pattern) {
     pattern = pattern.replace(re, function (match, escaped, ptn, flag) {
       let arg = args.shift();
       switch (flag) {
-        // eslint-disable-next-line no-fallthrough
         case 's':
           arg = String(arg);
           break;
@@ -53,6 +52,6 @@ export function format(pattern) {
   // arguments remain after formatting
   if (args.length) pattern += ' ' + args.join(' ');
   // update escaped %% values
-  pattern = pattern.replace(/%{2,2}/g, '%');
+  pattern = pattern.replace(/%{2}/g, '%');
   return '' + pattern;
 }