Skip to content

Commit 80e39dd

Browse files
committed
style: add eslint config
1 parent 7cee2e5 commit 80e39dd

38 files changed

+2691
-2484
lines changed

.eslintrc.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// eslint-disable-next-line no-undef
2+
module.exports = {
3+
env: {
4+
es2021: true,
5+
},
6+
extends: [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:prettier/recommended",
10+
],
11+
overrides: [],
12+
parser: "@typescript-eslint/parser",
13+
parserOptions: {
14+
ecmaVersion: "latest",
15+
sourceType: "module",
16+
},
17+
plugins: ["@typescript-eslint"],
18+
rules: {
19+
"@typescript-eslint/no-unused-vars": "off",
20+
"@typescript-eslint/no-explicit-any": "off",
21+
"@typescript-eslint/no-non-null-assertion": "off",
22+
"@typescript-eslint/ban-ts-comment": "off",
23+
"@typescript-eslint/ban-types": "off",
24+
"@typescript-eslint/no-this-alias": "off",
25+
"@typescript-eslint/no-empty-function": "off",
26+
"no-self-assign": "off",
27+
},
28+
};

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"tabWidth": 4,
3+
"useTabs": true
4+
}

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"name": "core",
33
"author": "wibus-wee <[email protected]>",
44
"license": "MIT",
5-
"scripts": {},
5+
"scripts": {
6+
"lint": "eslint ./packages"
7+
},
68
"devDependencies": {
79
"@types/node": "^18.11.17",
810
"@typescript-eslint/eslint-plugin": "^5.46.1",

packages/jwc-core/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from '@jwcjs/runtime';
2-
export * from './src'
1+
export * from "@jwcjs/runtime";
2+
export * from "./src";
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './metas.constant'
1+
export * from "./metas.constant";
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const COMPONENT_PROP_METADATA_KEY = 'jwc:component:props';
2-
export const COMPONENT_WATCHER_METADATA_KEY = 'jwc:component:watchers';
3-
export const COMPONENT_EVENT_METADATA_KEY = 'jwc:component:events';
1+
export const COMPONENT_PROP_METADATA_KEY = "jwc:component:props";
2+
export const COMPONENT_WATCHER_METADATA_KEY = "jwc:component:watchers";
3+
export const COMPONENT_EVENT_METADATA_KEY = "jwc:component:events";
+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { CustomElementProps } from "../types";
22

33
export function Component(options: CustomElementProps) {
4-
return function (_class: any) {
5-
// set the default value for the isMounted option
6-
if (options.isMounted === undefined) options.isMounted = true;
7-
if (customElements.get(options.name)) {
8-
console.warn(`The component ${options.name} already exists.`);
9-
}
10-
_class.$options = options; // add the options to the class
11-
customElements.define(options.name, _class, options.options || {});
12-
};
13-
}
4+
return function (_class: any) {
5+
// set the default value for the isMounted option
6+
if (options.isMounted === undefined) options.isMounted = true;
7+
if (customElements.get(options.name)) {
8+
console.warn(`The component ${options.name} already exists.`);
9+
}
10+
_class.$options = options; // add the options to the class
11+
customElements.define(options.name, _class, options.options || {});
12+
};
13+
}
+7-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { defineEvent } from "@jwcjs/reactively";
22

3-
43
export function Event(event: string): MethodDecorator {
5-
return (target, key, descriptor) => {
6-
defineEvent(target, {
7-
name: event,
8-
handler: descriptor.value,
9-
});
10-
}
11-
}
4+
return (target, key, descriptor) => {
5+
defineEvent(target, {
6+
name: event,
7+
handler: descriptor.value,
8+
});
9+
};
10+
}
+13-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { defineWatcher } from '@jwcjs/reactively';
2-
import { WatcherOptions } from '../types';
1+
import { defineWatcher } from "@jwcjs/reactively";
2+
import { WatcherOptions } from "../types";
33

4-
export * from './props';
5-
export * from './event';
6-
export * from './component';
4+
export * from "./props";
5+
export * from "./event";
6+
export * from "./component";
77

88
export function Watcher(options: WatcherOptions): MethodDecorator {
9-
return (target, key, descriptor) => {
10-
defineWatcher(target, {
11-
...options,
12-
callback: descriptor.value,
13-
callbackName: String(key),
14-
});
15-
}
16-
}
9+
return (target, key, descriptor) => {
10+
defineWatcher(target, {
11+
...options,
12+
callback: descriptor.value,
13+
callbackName: String(key),
14+
});
15+
};
16+
}

packages/jwc-core/src/decorators/props.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineProps } from "@jwcjs/reactively";
22
import { PropOptions } from "../types";
33

44
export function Prop(options: PropOptions): PropertyDecorator {
5-
return (target, key) => {
6-
defineProps(target, String(key), options);
7-
}
5+
return (target, key) => {
6+
defineProps(target, String(key), options);
7+
};
88
}

packages/jwc-core/src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import 'reflect-metadata';
1+
import "reflect-metadata";
22

3-
export * from './wc-class';
4-
export * from './types';
5-
export * from './decorators';
6-
export * from './constants';
3+
export * from "./wc-class";
4+
export * from "./types";
5+
export * from "./decorators";
6+
export * from "./constants";

packages/jwc-core/src/types/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './jwc-element.interface';
2-
export * from './watcher.interface';
1+
export * from "./jwc-element.interface";
2+
export * from "./watcher.interface";

0 commit comments

Comments
 (0)