1
0
Fork 0
mirror of https://github.com/n8n-io/n8n.git synced 2025-03-05 20:50:17 -08:00

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

👕 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
packages/design-system
.eslintrc.js
src
components
N8nFormInput
N8nFormInputs
types

View file

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

View file

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

View file

@ -57,7 +57,7 @@ export default Vue.extend({
data() { data() {
return { return {
showValidationWarnings: false, showValidationWarnings: false,
values: {} as { [key: string]: any }, values: {} as { [key: string]: unknown },
validity: {} as { [key: string]: boolean }, validity: {} as { [key: string]: boolean },
}; };
}, },
@ -89,7 +89,7 @@ export default Vue.extend({
}, },
}, },
methods: { methods: {
onInput(name: string, value: any) { onInput(name: string, value: unknown) {
this.values = { this.values = {
...this.values, ...this.values,
[name]: value, // eslint-disable-line @typescript-eslint/no-unsafe-assignment [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 = { export type RuleGroup = {
rules: Array<Rule | RuleGroup>; rules: Array<Rule | RuleGroup>;
defaultError?: { messageKey: string; options?: any }; defaultError?: { messageKey: string; options?: unknown };
}; };
export type Validatable = string | number | boolean | null | undefined; export type Validatable = string | number | boolean | null | undefined;
@ -10,8 +10,13 @@ export type Validatable = string | number | boolean | null | undefined;
export type IValidator = { export type IValidator = {
validate: ( validate: (
value: Validatable, value: Validatable,
config: any, config: unknown,
) => false | { messageKey: string; options?: any } | null; ) => false | { messageKey: string; options?: unknown } | null;
};
export type FormState = {
isTyping: boolean;
hasBlutted: boolean;
}; };
export type IFormInput = { export type IFormInput = {