Repository: plotly/dash
File: components/dash-core-components/src/components/Input.react.js (JavaScript)

Code before:
        base = convert(base);
        value = this.input.current.checkValidity() ? convert(value) : NaN;

        if (!isEquivalent(base, value)) {
            this.props.setProps({value});
        }
    }

    onEvent() {
        const {value} = this.input.current;
        const valueAsNumber = convert(value);
        if (this.props.type === 'number') {
            this.setPropValue(
                this.props.value,
                isNil(valueAsNumber) ? value : valueAsNumber
            );
        } else {
            this.props.setProps({value});
        }
        this.setState({pendingEvent: undefined});
    }

    debounceEvent(time = 0.5) {
        const {value} = this.input.current;
        const MILLISECONDS = 1000;
        time = time * MILLISECONDS;

        window.clearTimeout(this.state?.pendingEvent);
        const pendingEvent = window.setTimeout(() => {
            this.onEvent();
        }, time);

        this.setState({
            value,
            pendingEvent,
        });
    }

    onBlur() {
        this.props.setProps({
            n_blur: this.props.n_blur + 1,
            n_blur_timestamp: Date.now(),
        });
        this.input.current.checkValidity();
        return this.props.debounce === true && this.onEvent();
    }

    onKeyPress(e) {
        if (e.key === 'Enter') {
            this.props.setProps({
                n_submit: this.props.n_submit + 1,

Review comment (suggestion):
Better not to modify a var in place if we don't need to, just multiply it in the `setTimeout` call. And to your other question, you're welcome to add `1000` to the [already long list of exclusions in the linter](https://github.com/plotly/dash/blob/a7a12d180e16eac0a84b88e2b8dc8f7c7601cbaf/components/dash-core-components/.eslintrc#L120), I agree that it's a little silly to create a const just to satisfy the linter. But this would be a little more self-documenting if the var were called `seconds` or some such instead of `time`.

Code after:
        base = convert(base);
        value = this.input.current.checkValidity() ? convert(value) : NaN;

        if (!isEquivalent(base, value)) {
            this.props.setProps({value});
        }
    }

    onEvent() {
        const {value} = this.input.current;
        const valueAsNumber = convert(value);
        if (this.props.type === 'number') {
            this.setPropValue(
                this.props.value,
                isNil(valueAsNumber) ? value : valueAsNumber
            );
        } else {
            this.props.setProps({value});
        }
        this.setState({pendingEvent: undefined});
    }

    debounceEvent(seconds = 0.5) {
        const {value} = this.input.current;

        window.clearTimeout(this.state?.pendingEvent);
        const pendingEvent = window.setTimeout(() => {
            this.onEvent();
        }, seconds * 1000);

        this.setState({
            value,
            pendingEvent,
        });
    }

    onBlur() {
        this.props.setProps({
            n_blur: this.props.n_blur + 1,
            n_blur_timestamp: Date.now(),
        });
        this.input.current.checkValidity();
        return this.props.debounce === true && this.onEvent();
    }

    onKeyPress(e) {
        if (e.key === 'Enter') {
            this.props.setProps({
                n_submit: this.props.n_submit + 1,
                n_submit_timestamp: Date.now(),
            });