refactor: Enforce no-explicit-any in design-system (no-changelog) (#4937)

👕 Enforce `no-explicit-any` in design-system
This commit is contained in:
Iván Ovejero 2022-12-15 16:27:17 +01:00 committed by GitHub
parent 4208040495
commit d7b3d649d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 11 deletions

View file

@ -14,7 +14,6 @@ module.exports = {
// TODO: Remove these
'import/no-default-export': 'off',
'import/order': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',

View file

@ -75,12 +75,12 @@ import N8nInputLabel from '../N8nInputLabel';
import N8nCheckbox from '../N8nCheckbox';
import { getValidationError, VALIDATORS } from './validators';
import { Rule, RuleGroup, IValidator } from '../../types';
import { Rule, RuleGroup, IValidator, Validatable, FormState } from '../../types';
import { t } from '../../locale';
export interface Props {
value: any;
value: Validatable;
label: string;
infoText?: string;
required?: boolean;
@ -112,7 +112,7 @@ const props = withDefaults(defineProps<Props>(), {
const emit = defineEmits<{
(event: 'validate', shouldValidate: boolean): void;
(event: 'input', value: any): void;
(event: 'input', value: unknown): void;
(event: 'focus'): void;
(event: 'blur'): void;
(event: 'enter'): void;
@ -169,7 +169,7 @@ function onBlur() {
emit('blur');
}
function onInput(value: any) {
function onInput(value: FormState) {
state.isTyping = true;
emit('input', value);
}

View file

@ -57,7 +57,7 @@ export default Vue.extend({
data() {
return {
showValidationWarnings: false,
values: {} as { [key: string]: any },
values: {} as { [key: string]: unknown },
validity: {} as { [key: string]: boolean },
};
},
@ -89,7 +89,7 @@ export default Vue.extend({
},
},
methods: {
onInput(name: string, value: any) {
onInput(name: string, value: unknown) {
this.values = {
...this.values,
[name]: value, // eslint-disable-line @typescript-eslint/no-unsafe-assignment

View file

@ -1,8 +1,8 @@
export type Rule = { name: string; config?: any };
export type Rule = { name: string; config?: unknown };
export type RuleGroup = {
rules: Array<Rule | RuleGroup>;
defaultError?: { messageKey: string; options?: any };
defaultError?: { messageKey: string; options?: unknown };
};
export type Validatable = string | number | boolean | null | undefined;
@ -10,8 +10,13 @@ export type Validatable = string | number | boolean | null | undefined;
export type IValidator = {
validate: (
value: Validatable,
config: any,
) => false | { messageKey: string; options?: any } | null;
config: unknown,
) => false | { messageKey: string; options?: unknown } | null;
};
export type FormState = {
isTyping: boolean;
hasBlutted: boolean;
};
export type IFormInput = {