# HG changeset patch # User cin # Date 2021-09-02 00:35:46 # Node ID e5bb5e80ce96fc4ca0fbbf0b5390443a616e99fa # Parent 2c641d60ffc977a87224c3cc9e62d250345d0f4b fixed tslint errors, added support for private methods to @on() decorator diff --git a/djx/.eslintrc.json b/djx/.eslintrc.json new file mode 100644 --- /dev/null +++ b/djx/.eslintrc.json @@ -0,0 +1,25 @@ +{ + "env": { + "browser": true, + "amd": true + }, + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "sourceType": "script" + }, + "extends": "eslint:recommended", + "rules": { + "no-const-assign": "warn", + "no-this-before-super": "warn", + "no-undef": "error", + "no-unreachable": "warn", + "no-unused-vars": "warn", + "constructor-super": "warn", + "valid-typeof": "warn", + "semi" : "warn", + "no-invalid-this" : "error", + "no-console": "off" + } +} \ No newline at end of file diff --git a/djx/build.gradle b/djx/build.gradle --- a/djx/build.gradle +++ b/djx/build.gradle @@ -13,6 +13,7 @@ typescript { module = "amd" it.target = "es5" experimentalDecorators = true + noUnusedLocals = true jsx = "react" jsxFactory = "createElement" moduleResolution = "node" diff --git a/djx/src/main/ts/NlsBundle.ts b/djx/src/main/ts/NlsBundle.ts --- a/djx/src/main/ts/NlsBundle.ts +++ b/djx/src/main/ts/NlsBundle.ts @@ -1,9 +1,5 @@ import { MapOf, PromiseOrValue } from "@implab/core-amd/interfaces"; import { argumentNotEmptyString, isPromise, mixin } from "@implab/core-amd/safe"; -import { id as mid } from "module"; -import { TraceSource } from "@implab/core-amd/log/TraceSource"; - -const trace = TraceSource.get(mid); export type LocaleProvider = () => PromiseOrValue; @@ -19,10 +15,6 @@ function isCallback(v: ResolveCallbac return typeof v === "function"; } -function defaultResolver(module: string) { - return import(module).then(x => x && x.default ? x.default : x); -} - function chainObjects(o1: T, o2: T) { if (!o1) return o2; diff --git a/djx/src/main/ts/declare.ts b/djx/src/main/ts/declare.ts --- a/djx/src/main/ts/declare.ts +++ b/djx/src/main/ts/declare.ts @@ -1,7 +1,6 @@ import declare = require("dojo/_base/declare"); import { each } from "@implab/core-amd/safe"; import { Constructor } from "@implab/core-amd/interfaces"; -import dojo = require("dojo/_base/kernel"); // declare const declare: any; @@ -121,9 +120,7 @@ export function djclass(bc.bases, target.prototype); // bc - базовый класс, bc.prototype используется как super diff --git a/djx/src/main/ts/dom-inject.ts b/djx/src/main/ts/dom-inject.ts --- a/djx/src/main/ts/dom-inject.ts +++ b/djx/src/main/ts/dom-inject.ts @@ -94,7 +94,7 @@ class DomInject { throw e; } } -}; +} const instance = new DomInject(); export default instance; diff --git a/djx/src/main/ts/tsx/BuildContextBase.ts b/djx/src/main/ts/tsx/BuildContextBase.ts --- a/djx/src/main/ts/tsx/BuildContextBase.ts +++ b/djx/src/main/ts/tsx/BuildContextBase.ts @@ -3,9 +3,9 @@ import { RenditionBase } from "./Renditi /** * @deprecated use RenditionBase instead */ - export type BuildContextBase = RenditionBase; +export type BuildContextBase = RenditionBase; /** - * @deprecated use RenditionBase instead - */ - export const BuildContextBase = RenditionBase; + * @deprecated use RenditionBase instead + */ +export const BuildContextBase = RenditionBase; diff --git a/djx/src/main/ts/tsx/DjxFragment.ts b/djx/src/main/ts/tsx/DjxFragment.ts --- a/djx/src/main/ts/tsx/DjxFragment.ts +++ b/djx/src/main/ts/tsx/DjxFragment.ts @@ -1,5 +1,5 @@ /** Special functional component used to create a document fragment */ -export function DjxFragment({children}: {children?: Node | Node[]}){ +export function DjxFragment({ children }: { children?: Node | Node[] }) { const fragment = document.createDocumentFragment(); if (children) (children instanceof Array ? children : [children]).forEach(child => fragment.appendChild(child)); diff --git a/djx/src/main/ts/tsx/DjxWidgetBase.ts b/djx/src/main/ts/tsx/DjxWidgetBase.ts --- a/djx/src/main/ts/tsx/DjxWidgetBase.ts +++ b/djx/src/main/ts/tsx/DjxWidgetBase.ts @@ -1,7 +1,7 @@ -import { AbstractConstructor, djbase, djclass } from "../declare"; +import { djbase, djclass } from "../declare"; import _WidgetBase = require("dijit/_WidgetBase"); import _AttachMixin = require("dijit/_AttachMixin"); -import { Rendition, isNode, startupWidgets } from "./traits"; +import { Rendition, isNode } from "./traits"; import registry = require("dijit/registry"); // type Handle = dojo.Handle; @@ -25,7 +25,7 @@ export interface DjxWidgetBase extends djbase<_super, _AttachMixin>(_WidgetBase, _AttachMixin) { diff --git a/djx/src/main/ts/tsx/RenditionBase.ts b/djx/src/main/ts/tsx/RenditionBase.ts --- a/djx/src/main/ts/tsx/RenditionBase.ts +++ b/djx/src/main/ts/tsx/RenditionBase.ts @@ -90,7 +90,7 @@ export abstract class RenditionBase { if (node.parentNode) { @@ -100,9 +100,9 @@ export abstract class RenditionBase { } ) { let rendition = new FunctionRendition(() => render(target.get(prop))); - const _own = cleanupOrOwner instanceof Function ? cleanupOrOwner : (x: IRemovable) => cleanupOrOwner.own(x) + const _own = cleanupOrOwner instanceof Function ? cleanupOrOwner : (x: IRemovable) => cleanupOrOwner.own(x); _own(target.watch(prop, (_name, oldValue, newValue) => { if (oldValue !== newValue) { const newRendition = new FunctionRendition(() => render(newValue)); @@ -215,13 +215,13 @@ export function watch(eventName: E) => - , EV extends Event >( target: T, key: K, - descriptor: TypedPropertyDescriptor<(eventObj: EV) => void> | TypedPropertyDescriptor<() => void> + _descriptor: TypedPropertyDescriptor<(eventObj: EV) => void> | TypedPropertyDescriptor<() => void> ): any => { target._eventHandlers.push({ eventName, handlerMethod: key }); }; diff --git a/djx/src/test/ts/DeclareTests.ts b/djx/src/test/ts/DeclareTests.ts --- a/djx/src/test/ts/DeclareTests.ts +++ b/djx/src/test/ts/DeclareTests.ts @@ -1,5 +1,6 @@ import { Baz } from "./mock/Baz"; +// tslint:disable-next-line: no-console console.log("Declare tests"); const baz = new Baz(); @@ -7,4 +8,5 @@ const baz = new Baz(); const data: string[] = []; baz.writeHello(data); +// tslint:disable-next-line: no-console console.log(data.join("\n")); diff --git a/djx/src/test/ts/dummy.ts b/djx/src/test/ts/dummy.ts --- a/djx/src/test/ts/dummy.ts +++ b/djx/src/test/ts/dummy.ts @@ -1,7 +1,6 @@ import { test } from "./TestTraits"; import { delay } from "@implab/core-amd/safe"; import { assert } from "chai"; -import css = require("@implab/djx/css!my.css"); test("simple", (ok, fail, log) => { setTimeout(() => { diff --git a/djx/src/test/ts/view/MyWidget.tsx b/djx/src/test/ts/view/MyWidget.tsx --- a/djx/src/test/ts/view/MyWidget.tsx +++ b/djx/src/test/ts/view/MyWidget.tsx @@ -65,7 +65,7 @@ export class MyWidget extends djbase(Djx } @on("click") - _onClick() { + protected _onClick() { } } \ No newline at end of file diff --git a/djx/src/tsconfig.json b/djx/src/tsconfig.json --- a/djx/src/tsconfig.json +++ b/djx/src/tsconfig.json @@ -9,6 +9,7 @@ "target": "ES5", //"skipLibCheck": true, "jsx": "react", - "lib": ["es5", "es2015.promise", "es2015.symbol", "es2015.iterable", "dom", "scripthost"] + "lib": ["es5", "es2015.promise", "es2015.symbol", "es2015.iterable", "dom", "scripthost"], + "noUnusedLocals": true } } \ No newline at end of file diff --git a/djx/tslint.json b/djx/tslint.json new file mode 100644 --- /dev/null +++ b/djx/tslint.json @@ -0,0 +1,48 @@ +{ + "extends": "tslint:recommended", + "defaultSeverity": "warn", + "rules": { + "align": [ + true, + "parameters", + "statements" + ], + "interface-name": [ + false + ], + "max-line-length": [ + true, + 185 + ], + "quotemark": [true, "double", "avoid-escape"], + "member-access": false, + "semicolon": [true, "always", "ignore-bound-class-methods"], + "no-bitwise": false, + "no-empty": false, + "no-namespace": false, + "ordered-imports": false, + "no-return-await": true, + "no-floating-promises": true, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-whitespace" + ], + "object-literal-sort-keys": false, + "trailing-comma": [ + true, + { + "singleline": "never", + "multiline": "never" + } + ], + "variable-name": false, + "curly": false, + "array-type": false, + "arrow-parens": [ + true, + "ban-single-arg-parens" + ] + } +} \ No newline at end of file