Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix husky, lint and format code #1286

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ module.exports = {
// disable the rule for all files
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': ['error', {
"varsIgnorePattern": "_.*",
"argsIgnorePattern": "_.*"
}],
'import/named': 'off',
'import/no-unresolved': 'off',
'import/extensions': ['error', 'always', { ignorePackages: true }],
'import/no-duplicates': 'off',
'no-duplicate-imports': 'off',
'tsdoc/syntax': 'warn'
},
"env": {
"browser": true,
}
};
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- lint-staged
24,123 changes: 6,193 additions & 17,930 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
"format:prettier": "prettier \"**/*.js\" \"**/*.ts\" --write --ignore-path .gitignore",
"lint": "npm run lint:eslint && npm run lint:prettier",
"format": "npm run format:eslint && npm run format:prettier",
"test": "web-test-runner --coverage",
"test": "npm run lint && web-test-runner --coverage",
"test:snapshot": "web-test-runner --update-snapshots --coverage",
"test:manual": "web-test-runner --manual",
"test:watch": "web-test-runner --watch",
"test:unit": "web-test-runner --watch --group unit",
"test:integration": "web-test-runner --watch --group integration",
"doc:clean": "npx rimraf doc",
"doc:clean": "npx --no -- rimraf doc",
"doc:typedoc": "typedoc --plugin none --out doc src",
"doc:wca": "wca src --outDir doc/components",
"doc": "npm run doc:clean && npm run doc:typedoc && npm run doc:wca",
Expand All @@ -65,7 +65,8 @@
"release:major": "standard-version --release-as major",
"build": "npm run test && npm run build:notest && cp .nojekyll build/",
"build:notest": "npm run doc && snowpack build && workbox generateSW workbox-config.cjs",
"start": "snowpack dev"
"start": "snowpack dev",
"prepare": "husky install"
},
"devDependencies": {
"@commitlint/cli": "^13.1.0",
Expand All @@ -88,7 +89,7 @@
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-tsdoc": "^0.2.14",
"fast-check": "^2.19.0",
"husky": "^7.0.1",
"husky": "^8.0.0",
"lint-staged": "^11.1.2",
"prettier": "^2.3.2",
"sinon": "^11.1.2",
Expand All @@ -112,12 +113,6 @@
"singleQuote": true,
"arrowParens": "avoid"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.ts": [
"eslint --fix",
Expand Down
461 changes: 453 additions & 8 deletions public/ace/ext-searchbox.js

Large diffs are not rendered by default.

632 changes: 625 additions & 7 deletions public/ace/mode-xml.js

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions public/ace/theme-solarized_dark.js

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

27 changes: 19 additions & 8 deletions public/ace/theme-solarized_light.js

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

2,553 changes: 2,552 additions & 1 deletion public/ace/worker-xml.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/js/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,6 @@ export const officialPlugins = [
default: false,
kind: 'menu',
requireDoc: true,
position: 'middle'
}
position: 'middle',
},
];
4 changes: 2 additions & 2 deletions public/js/worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
importScripts('xmlvalidate.js');

onmessage = function(e) {
Module.ready.then(function(mod) {
onmessage = function (e) {
Module.ready.then(function (mod) {
if (e.data.name.toLowerCase().endsWith('.xsd'))
mod.init(e.data.content, e.data.name);
else mod.validate(e.data.content, e.data.name);
Expand Down
3,561 changes: 3,560 additions & 1 deletion public/js/xmlvalidate.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Editing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type EditingElement = Mixin<typeof Editing>;
/** @typeParam TBase - a type extending `LitElement`
* @returns `Base` with an `XMLDocument` property "`doc`" and an event listener
* applying [[`EditorActionEvent`]]s and dispatching [[`LogEvent`]]s. */
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function Editing<TBase extends LitElementConstructor>(Base: TBase) {
class EditingElement extends Base {
/** The `XMLDocument` to be edited */
Expand Down Expand Up @@ -445,6 +446,7 @@ export function Editing<TBase extends LitElementConstructor>(Base: TBase) {
);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args: any[]) {
super(...args);

Expand Down
4 changes: 4 additions & 0 deletions src/Hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ interface MenuPlugin {
/** Mixin that hosts the UI for Plugins, Settings and Logging */
export type HostingElement = Mixin<typeof Hosting>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function Hosting<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TBase extends new (...args: any[]) => PluggingElement &
LoggingElement &
SettingElement
Expand Down Expand Up @@ -207,6 +210,7 @@ export function Hosting<
];
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args: any[]) {
super(...args);

Expand Down
2 changes: 2 additions & 0 deletions src/Logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function getPluginName(src: string): string {
*/
export type LoggingElement = Mixin<typeof Logging>;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
class LoggingElement extends Base {
/** All [[`LogEntry`]]s received so far through [[`LogEvent`]]s. */
Expand Down Expand Up @@ -185,6 +186,7 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
super.performUpdate();
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args: any[]) {
super(...args);

Expand Down
5 changes: 4 additions & 1 deletion src/Plugging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function staticTagHtml(

type PluginKind = 'editor' | 'menu' | 'validator';
const menuPosition = ['top', 'middle', 'bottom'] as const;
type MenuPosition = typeof menuPosition[number];
type MenuPosition = (typeof menuPosition)[number];

export type Plugin = {
name: string;
Expand Down Expand Up @@ -176,7 +176,9 @@ const loadedPlugins = new Set<string>();
/** Mixin that manages Plugins in `localStorage` */
export type PluggingElement = Mixin<typeof Plugging>;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function Plugging<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
TBase extends new (...args: any[]) => EditingElement & LoggingElement
>(Base: TBase) {
class PluggingElement extends Base {
Expand Down Expand Up @@ -345,6 +347,7 @@ export function Plugging<
this.pluginDownloadUI.close();
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args: any[]) {
super(...args);

Expand Down
11 changes: 10 additions & 1 deletion src/Setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,18 @@ export function newLoadNsdocEvent(
});
}

// TODO(ca-d): unify document loading mechanisms
declare global {
interface ElementEventMap {
['load-nsdoc']: LoadNsdocEvent;
}
}

/** Mixin that saves [[`Settings`]] to `localStorage`, reflecting them in the
* `settings` property, setting them through `setSetting(setting, value)`. */
export type SettingElement = Mixin<typeof Setting>;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function Setting<TBase extends LitElementConstructor>(Base: TBase) {
class SettingElement extends Base {
/** Current [[`Settings`]] in `localStorage`, default to [[`defaults`]]. */
Expand Down Expand Up @@ -358,13 +366,14 @@ export function Setting<TBase extends LitElementConstructor>(Base: TBase) {
return new DOMParser().parseFromString(text, 'application/xml');
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...params: any[]) {
super(...params);

registerTranslateConfig({ loader, empty: key => key });
use(this.settings.language);

(<any>this).addEventListener('load-nsdoc', this.onLoadNsdoc);
this.addEventListener('load-nsdoc', this.onLoadNsdoc);
}

render(): TemplateResult {
Expand Down
2 changes: 2 additions & 0 deletions src/Waiting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
* [Pending State](https://github.com/justinfagnani/pending-state-protocol) */
export type WaitingElement = Mixin<typeof Waiting>;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function Waiting<TBase extends LitElementConstructor>(Base: TBase) {
class WaitingElement extends Base {
/** Whether the element is currently waiting for some async work. */
Expand All @@ -32,6 +33,7 @@ export function Waiting<TBase extends LitElementConstructor>(Base: TBase) {
this.waiting = this.work.size > 0;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args: any[]) {
super(...args);

Expand Down
2 changes: 2 additions & 0 deletions src/Wizarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { WizardDialog } from './wizard-dialog.js';
* queued onto on incoming [[`WizardEvent`]]s, first come first displayed. */
export type WizardingElement = Mixin<typeof Wizarding>;

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function Wizarding<TBase extends LitElementConstructor>(Base: TBase) {
class WizardingElement extends Base {
/** FIFO queue of [[`Wizard`]]s to display. */
Expand All @@ -37,6 +38,7 @@ export function Wizarding<TBase extends LitElementConstructor>(Base: TBase) {
);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args: any[]) {
super(...args);

Expand Down
Loading
Loading