Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add eslint unicorn plugin #213

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion library/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
'plugin:security/recommended',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import', 'redos-detector'],
plugins: ['@typescript-eslint', 'import', 'redos-detector', 'unicorn'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
Expand All @@ -35,5 +35,9 @@ module.exports = {
// regexp perf
'regexp/require-unicode-regexp': 'error', // /u flag is faster and enables regexp strict mode
'regexp/prefer-regexp-exec': 'error', // enforce that RegExp#exec is used instead of String#match if no global flag is provided, as exec is faster
'unicorn/better-regex': 'error', // auto-optimize regexps
'unicorn/prefer-regexp-test': 'error', // RegExp#test is fastest
'unicorn/prefer-string-replace-all': 'warn', // String#replaceAll avoids the need for resetting lastIndex when using cached global regex
'unicorn/prefer-string-starts-ends-with': 'error', // RegExp#startsWith and RegExp#endsWith are faster
},
};
11 changes: 6 additions & 5 deletions library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,19 @@
"publish": "npm publish"
},
"devDependencies": {
"@types/eslint": "^8.40.2",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"@types/eslint": "^8.44.4",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vitest/coverage-v8": "^0.33.0",
"eslint": "^8.43.0",
"eslint": "^8.51.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-redos-detector": "^2.1.1",
"eslint-plugin-regexp": "^1.15.0",
"eslint-plugin-security": "^1.7.1",
"eslint-plugin-unicorn": "^48.0.1",
"jsdom": "^22.1.0",
"tsup": "^7.1.0",
"typescript": "^5.1.3",
"typescript": "^5.2.2",
"vite": "^4.4.6",
"vitest": "^0.33.0"
}
Expand Down
2 changes: 1 addition & 1 deletion library/src/utils/isLuhnAlgo/isLuhnAlgo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
export function isLuhnAlgo(input: string) {
// Remove any non-digit chars
const number = input.replace(/\D/gu, '');
const number = input.replaceAll(/\D/gu, '');

// Create necessary variables
let length = number.length;
Expand Down
Loading