Skip to content

Commit

Permalink
update packs, remove maskSwapLength and add getUnmasked
Browse files Browse the repository at this point in the history
  • Loading branch information
lagden committed Oct 25, 2023
1 parent 683e6f6 commit a2448e4
Show file tree
Hide file tree
Showing 8 changed files with 897 additions and 876 deletions.
7 changes: 5 additions & 2 deletions .editorconfig
Expand Up @@ -2,13 +2,16 @@ root = true

[*]
indent_style = tab
indent_size = 2
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{md,yaml,yml,json}]
[*.{md,yml,yaml,json}]
indent_style = space
indent_size = 2

[*.{md,pug,marko}]
[*.{md,yml,yaml}]
trim_trailing_whitespace = false
60 changes: 41 additions & 19 deletions .eslintrc.yml
Expand Up @@ -2,41 +2,63 @@ root: true
env:
es2022: true
node: true
# parser: '@babel/eslint-parser'
parserOptions:
ecmaVersion: 13
sourceType: module
extends:
- xo
- eslint:recommended
- plugin:unicorn/recommended
rules:
camelcase: off
capitalized-comments: off
indent: [error, tab]
linebreak-style: [error, unix]
quotes: [error, single]
semi: [error, never]
semi-spacing:
- error
-
before: false
after: true
no-console: off
no-debugger: off
# no-multi-assign: off
# no-multiple-empty-lines:
# - error
# -
# max: 2
# maxBOF: 2
# maxEOF: 0
# no-new-func: off
no-undef-init: off
no-unused-expressions:
- error
-
allowShortCircuit: true
allowTernary: true
allowTaggedTemplates: true
camelcase: off
capitalized-comments: off
spaced-comment: off
no-unused-vars: off
padding-line-between-statements: off
no-undef-init: off
# no-empty-static-block: off
quotes: [error, single]
# require-atomic-updates: off
semi: [error, never]
semi-spacing:
- error
-
before: false
after: true
spaced-comment: off
# unicorn/consistent-destructuring: off
unicorn/filename-case: off
unicorn/prevent-abbreviations: off
unicorn/no-reduce: off
unicorn/no-array-reduce: off
# unicorn/import-style:
# - error
# -
# styles:
# util: false
# path:
# named: true
# unicorn/no-abusive-eslint-disable: off
# Bug no ctx.body Koa
require-atomic-updates: off
unicorn/no-array-reduce: off
# unicorn/no-negated-condition: off
# unicorn/no-null: off
unicorn/no-useless-undefined: off
unicorn/no-zero-fractions: off
# unicorn/prefer-dom-node-dataset: off
unicorn/prefer-event-target: off
unicorn/prefer-includes: off
# unicorn/prefer-object-from-entries: off
unicorn/prefer-query-selector: off
unicorn/prevent-abbreviations: off
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Expand Up @@ -24,10 +24,10 @@ jobs:
run: npm i -g pnpm

- name: Install dependencies
run: pnpm install
run: pnpm install --no-frozen-lockfile

- name: Run test
run: pnpm test
run: npm test

- name: Coveralls
uses: coverallsapp/github-action@master
Expand Down
50 changes: 15 additions & 35 deletions .gitignore
@@ -1,49 +1,29 @@
dist/*
# node
node_modules

# Yarn
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
!.yarnrc.yml
.pnp.*

# Logs
logs
*.log
npm-debug.log*
*.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
# Coverage
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
*.lcov
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity
11 changes: 9 additions & 2 deletions __test__/mask.spec.js
Expand Up @@ -61,7 +61,6 @@ test('input arr', () => {
input.value = ''
const mask = new Mask(input, {
mask: ['999.999.999-99', '99.999.999/9999-99'],
maskSwapLength: 14,
triggerOnDelete: true,
keyEvent: 'keyup',
})
Expand Down Expand Up @@ -91,7 +90,6 @@ test('input fn', () => {
},
triggerOnDelete: true,
keyEvent: 'keyup',
maskSwapLength: undefined,
})
for (const char of '10704') {
input.value += char
Expand Down Expand Up @@ -174,6 +172,15 @@ test('instance and destroy', () => {
_mask.destroy()
})

test('instance getUnmasked', () => {
const input = document.querySelector('#telefone')
input.value = '11968'
const mask = new Mask(input, {init: true})
expect(input.value).toBe('(11) 9-68')
expect(mask.getUnmasked()).toBe('11968')
mask.destroy()
})

test('throws instanced', () => {
expect(() => {
const input = document.querySelector('#telefone')
Expand Down
11 changes: 5 additions & 6 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@tadashi/mask",
"version": "4.1.0",
"version": "4.2.0",
"description": "The simple and tiny script for input mask",
"keywords": [
"mask",
Expand Down Expand Up @@ -32,11 +32,10 @@
"prepublishOnly": "npm test"
},
"devDependencies": {
"eslint": "8.41.0",
"eslint-config-xo": "0.43.1",
"eslint-plugin-unicorn": "47.0.0",
"jest": "29.5.0",
"jest-environment-jsdom": "29.5.0",
"eslint": "8.52.0",
"eslint-plugin-unicorn": "48.0.1",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"simulant": "0.2.2"
}
}

0 comments on commit a2448e4

Please sign in to comment.