Skip to content

Instantly share code, notes, and snippets.

View nbouvrette's full-sized avatar

Nicolas Bouvrette nbouvrette

View GitHub Profile
import { TSESTree } from '@typescript-eslint/types'
import { ESLintUtils } from '@typescript-eslint/utils'
import { RuleFunction } from '@typescript-eslint/utils/ts-eslint'
const createRule = ESLintUtils.RuleCreator((name) => `${name}`)
export const rule = createRule({
create: (context) => {
const checkFunction = (
node: TSESTree.FunctionDeclaration | TSESTree.ArrowFunctionExpression,
@nbouvrette
nbouvrette / inputTypeNumberPolyfill.js
Last active March 28, 2023 11:26
Stand alone JavaScript polyfill allow only numbers on input of type number.
/**
* Stand alone polyfill allow only numbers on input of type number.
*
* While input filtering is already supported by default by some browsers, maximum length has not been implemented by
* any. This script will solve both issue and make sure that only digits can be entered in input elements of type
* number. If the optional attribute `max` is set, it will calculate it's length and mimic the `maxlength` behavior on
* input of type text.
*
* Supports:
*