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"
|
||||
- run: npm ci
|
||||
- run: npm run build -w demo
|
||||
- run: npm run lint
|
||||
- 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": {
|
||||
"start": "npm run dev -w demo",
|
||||
"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",
|
||||
"dev": "npm run dev -w demo",
|
||||
"bump": "npm version patch -w",
|
||||
|
@ -28,8 +31,5 @@
|
|||
"demo",
|
||||
"packages/astro-reactive-form",
|
||||
"packages/astro-reactive-validator"
|
||||
],
|
||||
"dependencies": {
|
||||
"astro": "^1.4.4"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
tabWidth: 2,
|
||||
trailingComma: 'es5',
|
||||
useTabs: true,
|
||||
plugins: ['./node_modules/prettier-plugin-astro'],
|
||||
plugins: ['../../node_modules/prettier-plugin-astro'],
|
||||
overrides: [
|
||||
{
|
||||
files: '*.astro',
|
||||
|
|
|
@ -31,7 +31,7 @@ export interface FormControlBase {
|
|||
value?: string | number | string[];
|
||||
label?: string;
|
||||
labelPosition?: 'right' | 'left';
|
||||
placeholder? : string
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export interface Checkbox extends FormControlBase {
|
||||
|
@ -53,4 +53,3 @@ export interface Button extends FormControlBase {
|
|||
type: 'button';
|
||||
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 {
|
||||
private _name: string = '';
|
||||
private _name = '';
|
||||
private _type?: FormControlType | undefined = 'text';
|
||||
private _value?: string | number | null | string[];
|
||||
private _label?: string;
|
||||
|
@ -15,7 +22,7 @@ export class FormControl {
|
|||
this._value = value || null;
|
||||
this._label = label || '';
|
||||
this._labelPosition = labelPosition || 'left';
|
||||
this._placeholder = placeholder || ""
|
||||
this._placeholder = placeholder || '';
|
||||
}
|
||||
|
||||
get name() {
|
||||
|
@ -45,5 +52,4 @@ export class FormControl {
|
|||
setValue(value: string) {
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ export class FormGroup {
|
|||
controls: FormControl[];
|
||||
name?: string;
|
||||
|
||||
constructor(controls: FormControlBase[], name: string = '') {
|
||||
constructor(controls: FormControlBase[], name = '') {
|
||||
this.name = name;
|
||||
this.controls = controls.map((control) => new FormControl(control));
|
||||
}
|
||||
|
||||
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