1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-06-05 22:09:38 +02:00

refactor: ♻️ Refactor del codice per adattarlo alla nuova configurazione di ESLint

This commit is contained in:
Maicol Battistini
2021-09-29 15:32:31 +02:00
parent 0658fb19da
commit 034ee139d1
25 changed files with 58 additions and 49 deletions

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class Actions extends Component { export default class Actions extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class Card extends Component { export default class Card extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class Content extends Component { export default class Content extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class Media extends Component { export default class Media extends Component {
view(vnode) { view(vnode) {

View File

@ -1,6 +1,6 @@
import '@material/mwc-ripple'; import '@material/mwc-ripple';
import Component from '../Component'; import Component from '../Component.jsx';
export default class PrimaryAction extends Component { export default class PrimaryAction extends Component {
view(vnode) { view(vnode) {

View File

@ -10,7 +10,8 @@ interface Attributes extends Collection {
addStyles(...styles: string[]): void addStyles(...styles: string[]): void
} }
// noinspection SpellCheckingInspection // eslint-disable-next-line no-secrets/no-secrets
// noinspection SpellCheckingInspection,JSUnusedGlobalSymbols
/** /**
* @abstract * @abstract
* *
@ -119,7 +120,7 @@ export default class Component implements ClassComponent {
*/ */
$(selector?: string): JQuery { $(selector?: string): JQuery {
const $element: JQuery<HTMLElement> = $(this.element); const $element: JQuery<HTMLElement> = $(this.element);
return selector ? $element.find((element) => selector(element)) : $element; return selector ? $element.find(element => selector(element)) : $element;
} }
@ -129,7 +130,7 @@ export default class Component implements ClassComponent {
* *
* @see https://js.org/hyperscript.html#mselector,-attributes,-children * @see https://js.org/hyperscript.html#mselector,-attributes,-children
*/ */
static component(attributes = {}, children): Vnode { static component(attributes: {...} = {}, children): Vnode {
const componentAttributes: Record<string, any> = { ...attributes}; const componentAttributes: Record<string, any> = { ...attributes};
return m(this, componentAttributes, children); return m(this, componentAttributes, children);
@ -141,7 +142,7 @@ export default class Component implements ClassComponent {
* *
* @private * @private
*/ */
setAttrs(attributes: Object = {}): void { setAttrs(attributes: {...} = {}): void {
this.initAttrs(attributes); this.initAttrs(attributes);
if (attributes) { if (attributes) {
if ('children' in attributes) { if ('children' in attributes) {
@ -176,5 +177,5 @@ export default class Component implements ClassComponent {
* *
* @protected * @protected
*/ */
initAttrs(attributes: Object): void {} initAttrs(attributes: {...}): void {}
} }

View File

@ -2,8 +2,8 @@ import '@material/mwc-linear-progress';
import '@material/mwc-list/mwc-list-item'; import '@material/mwc-list/mwc-list-item';
import '@material/mwc-select'; import '@material/mwc-select';
import Component from '../Component'; import Component from '../Component.jsx';
import Mdi from '../Mdi'; import Mdi from '../Mdi.jsx';
export default class DataTable extends Component { export default class DataTable extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class TableBody extends Component { export default class TableBody extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
/** /**
* Attributes: * Attributes:

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class TableFooter extends Component { export default class TableFooter extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class TableHead extends Component { export default class TableHead extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
/** /**
* Attributes: * Attributes:

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class TableHeadRow extends Component { export default class TableHeadRow extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class TableRow extends Component { export default class TableRow extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class LayoutGrid extends Component { export default class LayoutGrid extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from '../Component'; import Component from '../Component.jsx';
export default class Row extends Component { export default class Row extends Component {
view(vnode) { view(vnode) {

View File

@ -1,4 +1,4 @@
import Component from './Component'; import Component from './Component.jsx';
export default class Mdi extends Component { export default class Mdi extends Component {
view(vnode) { view(vnode) {
@ -7,8 +7,8 @@ export default class Mdi extends Component {
} }
} }
/* /**
Quando MWC supporterà pienamente le icone SVG potremo fare così: Quando MWC supporterà pienamente le icone SVG si potrà fare così:
import * as mdi from '@mdi/js'; import * as mdi from '@mdi/js';
import {camelCase} from 'lodash/string'; import {camelCase} from 'lodash/string';
@ -16,4 +16,6 @@ export default class Mdi extends Component {
{...vnode.attrs} viewBox={vnode.attrs.viewBox ?? '0 0 24 24'}> {...vnode.attrs} viewBox={vnode.attrs.viewBox ?? '0 0 24 24'}>
<path d={vnode.attrs.icon ? mdi[camelCase(`mdi-${vnode.attrs.icon}`)] : ''} /> <path d={vnode.attrs.icon ? mdi[camelCase(`mdi-${vnode.attrs.icon}`)] : ''} />
</svg>; </svg>;
@see https://github.com/material-components/material-web/issues/1812
*/ */

View File

@ -2,7 +2,7 @@ import {Vnode} from 'mithril';
import {sync as render} from 'mithril-node-render'; import {sync as render} from 'mithril-node-render';
import {containsHTML} from '../utils'; import {containsHTML} from '../utils';
import Component from './Component'; import Component from './Component.jsx';
/** /**
* The `Page` component * The `Page` component
@ -13,8 +13,8 @@ export default class Page extends Component {
page: { page: {
component: string, component: string,
locale: string, locale: string,
props: Object, props: {...},
translations: Object, translations: {...},
url: string, url: string,
version: string, version: string,
... ...
@ -36,7 +36,7 @@ export default class Page extends Component {
*/ */
__( __(
key: string | Vnode, key: string | Vnode,
replace: Object | boolean = {}, replace: {...} | boolean = {},
returnAsString: boolean = false returnAsString: boolean = false
): Vnode { ): Vnode {
let translation = (this.page.translations && this.page.translations[key]) let translation = (this.page.translations && this.page.translations[key])

View File

@ -4,15 +4,15 @@ import '@material/mwc-fab';
import collect from 'collect.js'; import collect from 'collect.js';
import {Children} from 'mithril'; import {Children} from 'mithril';
import DataTable from '../DataTable/DataTable'; import DataTable from '../DataTable/DataTable.jsx';
import TableBody from '../DataTable/TableBody'; import TableBody from '../DataTable/TableBody.jsx';
import TableCell from '../DataTable/TableCell'; import TableCell from '../DataTable/TableCell.jsx';
import TableHead from '../DataTable/TableHead'; import TableHead from '../DataTable/TableHead.jsx';
import TableHeadCell from '../DataTable/TableHeadCell'; import TableHeadCell from '../DataTable/TableHeadCell.jsx';
import TableHeadRow from '../DataTable/TableHeadRow'; import TableHeadRow from '../DataTable/TableHeadRow.jsx';
import TableRow from '../DataTable/TableRow'; import TableRow from '../DataTable/TableRow.jsx';
import Mdi from '../Mdi'; import Mdi from '../Mdi.jsx';
import Page from '../Page'; import Page from '../Page.jsx';
export type ColumnT = { export type ColumnT = {
id?: string, id?: string,
@ -24,11 +24,11 @@ export type ColumnT = {
* @abstract * @abstract
*/ */
export default class RecordsPage extends Page { export default class RecordsPage extends Page {
columns: Object<string | ColumnT> | Array<ColumnT>; columns: string[] | {[string]: ColumnT} | ColumnT[];
rows: Array<Array<string>> = []; rows: string[][] = [];
dialogs: Array<Children>; dialogs: Children[];
tableColumns(): Children { tableColumns(): Children {
return collect(this.columns) return collect(this.columns)

View File

@ -1 +1 @@
export {default as RecordsPage} from './RecordsPage'; export {default as RecordsPage} from './RecordsPage.jsx';

View File

@ -1,3 +1,5 @@
// noinspection JSUnusedGlobalSymbols
export * from './Card'; export * from './Card';
export { default as Component } from './Component.jsx'; export { default as Component } from './Component.jsx';
export * from './DataTable'; export * from './DataTable';

View File

@ -13,13 +13,13 @@ import Mithril from 'mithril';
import logoUrl from '@/static/images/logo_completo.png'; import logoUrl from '@/static/images/logo_completo.png';
import Card from '../Components/Card/Card'; import Card from '../Components/Card/Card.jsx';
import Content from '../Components/Card/Content'; import Content from '../Components/Card/Content.jsx';
import Cell from '../Components/Grid/Cell'; import Cell from '../Components/Grid/Cell.jsx';
import LayoutGrid from '../Components/Grid/LayoutGrid'; import LayoutGrid from '../Components/Grid/LayoutGrid.jsx';
import Row from '../Components/Grid/Row'; import Row from '../Components/Grid/Row.jsx';
import Mdi from '../Components/Mdi'; import Mdi from '../Components/Mdi.jsx';
import Page from '../Components/Page'; import Page from '../Components/Page.jsx';
export default class SetupPage extends Page { export default class SetupPage extends Page {
languages() { languages() {

View File

@ -1,2 +1,4 @@
// noinspection JSUnusedGlobalSymbols
export { default as SetupPage } from './SetupPage.jsx'; export { default as SetupPage } from './SetupPage.jsx';

View File

@ -1,3 +1,5 @@
// noinspection JSUnusedGlobalSymbols
export { default as Drawer } from './MaterialDrawer'; export { default as Drawer } from './MaterialDrawer';
export { default as TopAppBar } from './TopAppBar'; export { default as TopAppBar } from './TopAppBar';

View File

@ -3,7 +3,7 @@
/** /**
* Check if class/object A is the same as or a subclass of class B. * Check if class/object A is the same as or a subclass of class B.
*/ */
export function subclassOf(A: Object, B: Object): boolean { export function subclassOf(A: {...}, B: {...}): boolean {
// noinspection JSUnresolvedVariable // noinspection JSUnresolvedVariable
return A && (A === B || A.prototype instanceof B); return A && (A === B || A.prototype instanceof B);
} }