Browse Source

Upgrade eslint configs

Zihua Li 2 years ago
parent
commit
ac9c20dc8a
10 changed files with 526 additions and 827 deletions
  1. 14 9
      .eslintrc.json
  2. 10 0
      .gitignore
  3. 10 0
      .npmignore
  4. 1 1
      blots/scroll.ts
  5. 2 1
      core/emitter.ts
  6. 23 3
      core/quill.ts
  7. 1 3
      formats/table.ts
  8. 1 1
      formats/video.ts
  9. 451 779
      package-lock.json
  10. 13 30
      package.json

+ 14 - 9
.eslintrc.json

@@ -1,5 +1,10 @@
 {
-  "extends": ["airbnb-base", "airbnb-typescript/base", "prettier"],
+  "extends": [
+    "eslint:recommended",
+    "plugin:@typescript-eslint/recommended",
+    "plugin:prettier/recommended"
+  ],
+  "parser": "@typescript-eslint/parser",
   "parserOptions": {
     "project": "./tsconfig.json"
   },
@@ -8,7 +13,7 @@
     "commonjs": true,
     "es6": true
   },
-  "plugins": ["prettier"],
+  "plugins": ["prettier", "@typescript-eslint"],
   "settings": {
     "import/resolver": {
       "webpack": {
@@ -16,7 +21,9 @@
       }
     }
   },
+  "ignorePatterns": ["**/*.d.ts", "**/*.js"],
   "rules": {
+    "arrow-parens": ["error", "as-needed"],
     "class-methods-use-this": "off",
     "import/no-cycle": "off",
     "no-restricted-exports": "off",
@@ -24,17 +31,15 @@
     "@typescript-eslint/lines-between-class-members": "off",
     "@typescript-eslint/space-before-function-paren": "off",
     "@typescript-eslint/no-use-before-define": "off",
+    "@typescript-eslint/no-this-alias": "off",
     "@typescript-eslint/quotes": "off",
     "@typescript-eslint/comma-dangle": "off",
-    "import/no-extraneous-dependencies": [
-      "error",
-      {
-        "devDependencies": ["_develop/*.js", "test/**/*.js"]
-      }
-    ],
+    "@typescript-eslint/ban-ts-comment": "off",
+    "@typescript-eslint/no-empty-function": "off",
+    "@typescript-eslint/ban-types": "off",
+    "@typescript-eslint/no-explicit-any": "off",
     "no-param-reassign": "off",
     "no-use-before-define": ["error", { "functions": false, "classes": false }],
-    "import/named": "error",
     "max-classes-per-file": "off",
     "prettier/prettier": "error"
   }

+ 10 - 0
.gitignore

@@ -8,4 +8,14 @@
 /docs/_site
 /src
 *.d.ts
+*.js.map
 *.log
+
+blots/*.js
+core/*.js
+formats/*.js
+modules/*.js
+themes/*.js
+
+core.js
+quill.js

+ 10 - 0
.npmignore

@@ -0,0 +1,10 @@
+*.ts
+!*.d.ts
+.*
+Gemfile
+Gemfile.lock
+_develop
+.github
+.vscode
+docs
+test

+ 1 - 1
blots/scroll.ts

@@ -21,7 +21,7 @@ interface UpdatableEmbed {
 }
 
 function isUpdatable(blot: Blot): blot is Blot & UpdatableEmbed {
-  return typeof ((blot as unknown) as any).updateContent === 'function';
+  return typeof (blot as unknown as any).updateContent === 'function';
 }
 
 class Scroll extends ScrollBlot {

+ 2 - 1
core/emitter.ts

@@ -66,6 +66,7 @@ class Emitter extends EventEmitter<string> {
   }
 }
 
-export type EmitterSource = typeof Emitter.sources[keyof typeof Emitter.sources];
+export type EmitterSource =
+  typeof Emitter.sources[keyof typeof Emitter.sources];
 
 export default Emitter;

+ 23 - 3
core/quill.ts

@@ -361,10 +361,30 @@ class Quill {
     );
   }
 
-  formatText(index, length, name, value, source) {
+  formatText(
+    range: { index: number; length: number },
+    name: string,
+    value: unknown,
+    source?: EmitterSource,
+  ): Delta;
+  formatText(
+    index: number,
+    length: number,
+    name: string,
+    value: unknown,
+    source: EmitterSource,
+  ): Delta;
+  formatText(
+    index: number | { index: number; length: number },
+    length: number | string,
+    name: string | unknown,
+    value?: unknown | EmitterSource,
+    source?: EmitterSource,
+  ): Delta {
     let formats;
     // eslint-disable-next-line prefer-const
     [index, length, formats, source] = overload(
+      // @ts-expect-error
       index,
       length,
       name,
@@ -561,7 +581,7 @@ class Quill {
             typeof Emitter['events']['SELECTION_CHANGE'],
             Range,
             Range,
-            EmitterSource
+            EmitterSource,
           ]
     ) => void,
   ): this;
@@ -780,7 +800,7 @@ type NormalizedIndexLength = [
   number,
   number,
   Record<string, unknown>,
-  EmitterSource
+  EmitterSource,
 ];
 function overload(index: number, source?: EmitterSource): NormalizedIndexLength;
 function overload(

+ 1 - 3
formats/table.ts

@@ -205,9 +205,7 @@ TableRow.allowedChildren = [TableCell];
 TableCell.requiredContainer = TableRow;
 
 function tableId() {
-  const id = Math.random()
-    .toString(36)
-    .slice(2, 6);
+  const id = Math.random().toString(36).slice(2, 6);
   return `row-${id}`;
 }
 

+ 1 - 1
formats/video.ts

@@ -26,7 +26,7 @@ class Video extends BlockEmbed {
   }
 
   static sanitize(url: string) {
-    return Link.sanitize(url); // eslint-disable-line import/no-named-as-default-member
+    return Link.sanitize(url);
   }
 
   static value(domNode: Element) {

File diff suppressed because it is too large
+ 451 - 779
package-lock.json


+ 13 - 30
package.json

@@ -6,24 +6,6 @@
   "homepage": "http://quilljs.com",
   "main": "dist/quill.js",
   "types": "dist/typings/quill.d.ts",
-  "files": [
-    "assets",
-    "blots",
-    "core",
-    "formats",
-    "modules",
-    "themes",
-    "ui",
-    "dist/quill.bubble.css",
-    "dist/quill.snow.css",
-    "dist/quill.core.css",
-    "dist/quill.js",
-    "dist/quill.core.js",
-    "dist/quill.min.js.map",
-    "dist/quill.min.js",
-    "core.ts",
-    "quill.ts"
-  ],
   "config": {
     "ports": {
       "proxy": "9000",
@@ -43,19 +25,17 @@
   "devDependencies": {
     "@babel/core": "^7.9.0",
     "@babel/preset-env": "^7.9.5",
-    "@typescript-eslint/eslint-plugin": "^5.28.0",
-    "@typescript-eslint/parser": "^5.28.0",
+    "@typescript-eslint/eslint-plugin": "^5.33.1",
+    "@typescript-eslint/parser": "^5.33.1",
     "babel-loader": "^8.1.0",
     "babel-plugin-istanbul": "^6.0.0",
     "css-loader": "^3.5.1",
     "eslint": "^7.32.0",
-    "eslint-config-airbnb-base": "^15.0.0",
-    "eslint-config-airbnb-typescript": "^17.0.0",
-    "eslint-config-prettier": "^6.10.1",
+    "eslint-config-prettier": "^8.5.0",
     "eslint-import-resolver-webpack": "~0.12.1",
     "eslint-plugin-import": "^2.26.0",
     "eslint-plugin-jsx-a11y": "^6.2.3",
-    "eslint-plugin-prettier": "^3.1.2",
+    "eslint-plugin-prettier": "^4.2.1",
     "highlight.js": "^9.18.1",
     "html-loader": "~1.1.0",
     "http-proxy": "^1.18.0",
@@ -68,14 +48,14 @@
     "karma-sauce-launcher": "^4.1.2",
     "lodash": "^4.17.15",
     "mini-css-extract-plugin": "~0.9.0",
-    "prettier": "^1.17.0",
+    "prettier": "^2.7.1",
     "puppeteer": "^2.1.1",
     "style-loader": "~1.1.3",
     "stylus": "~0.54.7",
     "stylus-loader": "^3.0.2",
-    "ts-loader": "^6.2.2",
-    "ts-node": "^10.8.1",
-    "typescript": "^4.6.4",
+    "ts-loader": "^8.4.0",
+    "ts-node": "^10.9.1",
+    "typescript": "^4.7.4",
     "webpack": "^4.42.1",
     "webpack-cli": "^3.3.11",
     "webpack-dev-server": "^3.10.3"
@@ -90,14 +70,17 @@
   },
   "prettier": {
     "singleQuote": true,
-    "trailingComma": "all"
+    "trailingComma": "all",
+    "arrowParens": "avoid"
   },
   "scripts": {
-    "build": "npm run lint && npm run build:webpack",
+    "build": "npm run lint && npm run build:typescript && npm run build:webpack",
+    "build:typescript": "tsc",
     "build:webpack": "webpack --config _develop/webpack.config.js; rm dist/quill.core dist/quill.bubble dist/quill.snow",
     "build:release": "./_develop/scripts/release.sh",
     "develop": "npm run start",
     "lint": "eslint .",
+    "prepare": "npm run build",
     "start": "npm run build:webpack; bundle exec foreman start -f _develop/procfile",
     "test": "npm run test:unit; npm run test:random",
     "test:all": "npm run test:unit; npm run test:functional; npm run test:random",

Some files were not shown because too many files changed in this diff