Skip to content

Commit

Permalink
Apply linter rules to test files
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Jul 30, 2023
1 parent 59955fc commit 6c12af8
Show file tree
Hide file tree
Showing 20 changed files with 280 additions and 266 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
]
}
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 2 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,8 @@
"vite": "^4.4.7",
"vitest": "^0.33.0"
},
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
]
}
},
"prettier": {
"singleQuote": true,
"trailingComma": "all"
"singleQuote": true
},
"license": "BSD-3-Clause",
"repository": {
Expand All @@ -62,7 +39,7 @@
"scripts": {
"build": "vite build",
"build:types": "tsc --emitDeclarationOnly && api-extractor run && del-cli dist/typings",
"lint": "eslint 'src/**/*.ts'",
"lint": "eslint 'src/**/*.ts' 'test/**/*.ts'",
"prepare": "npm run build && npm run build:types",
"test": "npm run test:unit && npm run test:types",
"test:unit": "vitest",
Expand Down
6 changes: 3 additions & 3 deletions src/attributor/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ class StyleAttributor extends Attributor {
if (!this.canAdd(node, value)) {
return false;
}
// @ts-expect-error
// @ts-expect-error Fix me later
node.style[camelize(this.keyName)] = value;
return true;
}

public remove(node: HTMLElement): void {
// @ts-expect-error
// @ts-expect-error Fix me later
node.style[camelize(this.keyName)] = '';
if (!node.getAttribute('style')) {
node.removeAttribute('style');
}
}

public value(node: HTMLElement): string {
// @ts-expect-error
// @ts-expect-error Fix me later
const value = node.style[camelize(this.keyName)];
return this.canAdd(node, value) ? value : '';
}
Expand Down
2 changes: 1 addition & 1 deletion src/blot/abstract/parent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class ParentBlot extends ShadowBlot implements Parent {
// from DOM but MutationRecord is correct in its reported removal
if (
node.parentNode != null &&
// @ts-expect-error
// @ts-expect-error Fix me later
node.tagName !== 'IFRAME' &&
document.body.compareDocumentPosition(node) &
Node.DOCUMENT_POSITION_CONTAINED_BY
Expand Down
7 changes: 5 additions & 2 deletions src/blot/abstract/shadow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ class ShadowBlot implements Blot {

public prev: Blot | null;
public next: Blot | null;
// @ts-expect-error
// @ts-expect-error Fix me later
public parent: Parent;

// Hack for accessing inherited static methods
get statics(): any {
return this.constructor;
}
constructor(public scroll: Root, public domNode: Node) {
constructor(
public scroll: Root,
public domNode: Node,
) {
Registry.blots.set(domNode, this);
this.prev = null;
this.next = null;
Expand Down
5 changes: 4 additions & 1 deletion src/blot/scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class ScrollBlot extends ParentBlot implements Root {

public observer: MutationObserver;

constructor(public registry: Registry, node: HTMLDivElement) {
constructor(
public registry: Registry,
node: HTMLDivElement,
) {
// @ts-expect-error scroll is the root with no parent
super(null, node);
this.scroll = this;
Expand Down
4 changes: 2 additions & 2 deletions src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class Registry implements RegistryInterface {
}
const blotClass = match as BlotConstructor;
const node =
// @ts-expect-error
// @ts-expect-error Fix me later
input instanceof Node || input.nodeType === Node.TEXT_NODE
? input
: blotClass.create(value);
Expand All @@ -74,7 +74,7 @@ export default class Registry implements RegistryInterface {
let match;
if (typeof query === 'string') {
match = this.types[query] || this.attributes[query];
// @ts-expect-error
// @ts-expect-error Fix me later
} else if (query instanceof Text || query.nodeType === Node.TEXT_NODE) {
match = this.types.text;
} else if (typeof query === 'number') {
Expand Down
6 changes: 3 additions & 3 deletions test/__helpers__/registry/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class ImageBlot extends EmbedBlot {
static readonly blotName = 'image';
static tagName = 'IMG';
static create(value: string) {
let node = super.create(value) as HTMLElement;
const node = super.create(value) as HTMLElement;
if (typeof value === 'string') {
node.setAttribute('src', value);
}
Expand Down Expand Up @@ -39,15 +39,15 @@ export class VideoBlot extends EmbedBlot {
static readonly blotName = 'video';
static tagName = 'VIDEO';
static create(value: string) {
let node = super.create(value) as HTMLVideoElement;
const node = super.create(value) as HTMLVideoElement;
if (typeof value === 'string') {
node.setAttribute('src', value);
}
return node;
}

static formats(domNode: HTMLVideoElement) {
let formats: Partial<{ height: string; width: string }> = {};
const formats: Partial<{ height: string; width: string }> = {};
const height = domNode.getAttribute('height');
const width = domNode.getAttribute('width');
height && (formats.height = height);
Expand Down
Loading

0 comments on commit 6c12af8

Please sign in to comment.