Skip to content

Commit

Permalink
Upgrade eslint configs
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Aug 16, 2022
1 parent aad907d commit ac9c20d
Show file tree
Hide file tree
Showing 11 changed files with 788 additions and 1,210 deletions.
23 changes: 14 additions & 9 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand All @@ -8,33 +13,33 @@
"commonjs": true,
"es6": true
},
"plugins": ["prettier"],
"plugins": ["prettier", "@typescript-eslint"],
"settings": {
"import/resolver": {
"webpack": {
"config": "_develop/webpack.config.js"
}
}
},
"ignorePatterns": ["**/*.d.ts", "**/*.js"],
"rules": {
"arrow-parens": ["error", "as-needed"],
"class-methods-use-this": "off",
"import/no-cycle": "off",
"no-restricted-exports": "off",
"@typescript-eslint/indent": "off",
"@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"
}
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.ts
!*.d.ts
.*
Gemfile
Gemfile.lock
_develop
.github
.vscode
docs
test
2 changes: 1 addition & 1 deletion blots/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion core/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
26 changes: 23 additions & 3 deletions core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -561,7 +581,7 @@ class Quill {
typeof Emitter['events']['SELECTION_CHANGE'],
Range,
Range,
EmitterSource
EmitterSource,
]
) => void,
): this;
Expand Down Expand Up @@ -780,7 +800,7 @@ type NormalizedIndexLength = [
number,
number,
Record<string, unknown>,
EmitterSource
EmitterSource,
];
function overload(index: number, source?: EmitterSource): NormalizedIndexLength;
function overload(
Expand Down
4 changes: 1 addition & 3 deletions formats/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}

Expand Down
2 changes: 1 addition & 1 deletion formats/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit ac9c20d

Please sign in to comment.