devops: set up package linting (#53)
This commit is contained in:
parent
955b9ca27c
commit
f1485808c9
7 changed files with 1496 additions and 4214 deletions
1
.github/workflows/build-and-test.yml
vendored
1
.github/workflows/build-and-test.yml
vendored
|
@ -27,4 +27,5 @@ jobs:
|
||||||
cache: "npm"
|
cache: "npm"
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npm run build -w demo
|
- run: npm run build -w demo
|
||||||
|
- run: npm run lint
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|
5678
package-lock.json
generated
5678
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -16,6 +16,9 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run dev -w demo",
|
"start": "npm run dev -w demo",
|
||||||
"test": "npm run test --workspaces --if-present",
|
"test": "npm run test --workspaces --if-present",
|
||||||
|
"lint": "npm run lint --workspaces --if-present",
|
||||||
|
"lint:fix": "npm run lint:fix --workspaces --if-present",
|
||||||
|
"build": "npm run build --workspaces --if-present",
|
||||||
"test:watch": "npm run test:watch --workspaces --if-present",
|
"test:watch": "npm run test:watch --workspaces --if-present",
|
||||||
"dev": "npm run dev -w demo",
|
"dev": "npm run dev -w demo",
|
||||||
"bump": "npm version patch -w",
|
"bump": "npm version patch -w",
|
||||||
|
@ -28,8 +31,5 @@
|
||||||
"demo",
|
"demo",
|
||||||
"packages/astro-reactive-form",
|
"packages/astro-reactive-form",
|
||||||
"packages/astro-reactive-validator"
|
"packages/astro-reactive-validator"
|
||||||
],
|
]
|
||||||
"dependencies": {
|
|
||||||
"astro": "^1.4.4"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
||||||
tabWidth: 2,
|
tabWidth: 2,
|
||||||
trailingComma: 'es5',
|
trailingComma: 'es5',
|
||||||
useTabs: true,
|
useTabs: true,
|
||||||
plugins: ['./node_modules/prettier-plugin-astro'],
|
plugins: ['../../node_modules/prettier-plugin-astro'],
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
files: '*.astro',
|
files: '*.astro',
|
||||||
|
|
|
@ -31,7 +31,7 @@ export interface FormControlBase {
|
||||||
value?: string | number | string[];
|
value?: string | number | string[];
|
||||||
label?: string;
|
label?: string;
|
||||||
labelPosition?: 'right' | 'left';
|
labelPosition?: 'right' | 'left';
|
||||||
placeholder? : string
|
placeholder?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Checkbox extends FormControlBase {
|
export interface Checkbox extends FormControlBase {
|
||||||
|
@ -53,4 +53,3 @@ export interface Button extends FormControlBase {
|
||||||
type: 'button';
|
type: 'button';
|
||||||
callBack: () => void;
|
callBack: () => void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
import type { FormControlType, Button, Checkbox, FormControlBase, Radio, Submit } from "../types";
|
import type {
|
||||||
|
FormControlType,
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
FormControlBase,
|
||||||
|
Radio,
|
||||||
|
Submit,
|
||||||
|
} from './form-control-types';
|
||||||
|
|
||||||
export class FormControl {
|
export class FormControl {
|
||||||
private _name: string = '';
|
private _name = '';
|
||||||
private _type?: FormControlType | undefined = 'text';
|
private _type?: FormControlType | undefined = 'text';
|
||||||
private _value?: string | number | null | string[];
|
private _value?: string | number | null | string[];
|
||||||
private _label?: string;
|
private _label?: string;
|
||||||
|
@ -15,7 +22,7 @@ export class FormControl {
|
||||||
this._value = value || null;
|
this._value = value || null;
|
||||||
this._label = label || '';
|
this._label = label || '';
|
||||||
this._labelPosition = labelPosition || 'left';
|
this._labelPosition = labelPosition || 'left';
|
||||||
this._placeholder = placeholder || ""
|
this._placeholder = placeholder || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
|
@ -45,5 +52,4 @@ export class FormControl {
|
||||||
setValue(value: string) {
|
setValue(value: string) {
|
||||||
this._value = value;
|
this._value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@ export class FormGroup {
|
||||||
controls: FormControl[];
|
controls: FormControl[];
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|
||||||
constructor(controls: FormControlBase[], name: string = '') {
|
constructor(controls: FormControlBase[], name = '') {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.controls = controls.map((control) => new FormControl(control));
|
this.controls = controls.map((control) => new FormControl(control));
|
||||||
}
|
}
|
||||||
|
|
||||||
get(name: string): FormControl | undefined {
|
get(name: string): FormControl | undefined {
|
||||||
return this.controls.find(control => control.name === name);
|
return this.controls.find((control) => control.name === name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue