Skip to content

Commit 0eeadaa

Browse files
authored
Merge pull request #2 from moser-jose/shortname
update the shortname
2 parents 9d2a2d9 + a9c206c commit 0eeadaa

File tree

14 files changed

+5040
-125
lines changed

14 files changed

+5040
-125
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
dist/
3+
coverage/

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
coverage/
4+
package-lock.json
5+
*.d.ts

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"useTabs": false,
8+
"bracketSpacing": true,
9+
"arrowParens": "avoid",
10+
"endOfLine": "lf"
11+
}

.vscode/launch.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
9+
]
10+
}

.vscode/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": "explicit"
5+
},
6+
"editor.defaultFormatter": "esbenp.prettier-vscode",
7+
"eslint.validate": ["typescript", "javascript"],
8+
"editor.diagnostics.enabled": true,
9+
"typescript.reportStyleChecksAsWarnings": true,
10+
"editor.quickSuggestions": {
11+
"other": true,
12+
"comments": false,
13+
"strings": false
14+
}
15+
}

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
`shortname-js` is a JavaScript function designed to shorten names (Portuguese - PT 🇵🇹 | BR 🇧🇷 | AO 🇦🇴) in a simple and user-friendly way. The function allows users to quickly enter full names and receive abbreviated versions of those names in return.
44

5-
[![The MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT) [![The MIT License](https://img.shields.io/github/package-json/v/moser-jose/shortname-js)](https://github.com/moser-jose/shortname-js)
5+
[![The MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)
6+
[![Version](https://img.shields.io/github/package-json/v/moser-jose/shortname-js)](https://github.com/moser-jose/shortname-js)
7+
[![npm](https://img.shields.io/npm/v/@mosmmy/shortname-js)](https://www.npmjs.com/package/@mosmmy/shortname-js)
8+
[![npm downloads](https://img.shields.io/npm/dm/@mosmmy/shortname-js)](https://www.npmjs.com/package/@mosmmy/shortname-js)
9+
[![npm bundle size](https://img.shields.io/bundlephobia/min/@mosmmy/shortname-js)](https://bundlephobia.com/package/@mosmmy/shortname-js)
10+
[![TypeScript](https://img.shields.io/badge/TypeScript-supported-blue)](https://www.typescriptlang.org/)
11+
[![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io/)
12+
[![Jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io/)
13+
[![Coverage Status](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/moser-jose/shortname-js)
14+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)
15+
[![GitHub stars](https://img.shields.io/github/stars/moser-jose/shortname-js?style=social)](https://github.com/moser-jose/shortname-js/stargazers)
616

717
## Install
818

@@ -18,11 +28,13 @@
1828

1929
```javascript
2030

21-
import shortName = '@mosmmy/shortname-js'
31+
import { shortName } from '@mosmmy/shortname-js'
2232

2333
console.log(shortName('Jorge Pedro André dos Santos')) //Jorge P. A. dos Santos
2434

25-
console.log(shortName('Pedro de Sousa André')) //**Pedro** S. André
35+
console.log(shortName('Pedro de Sousa André')) //Pedro de S. André
36+
37+
console.log(shortName('Marilda dos Santos Pedro de Souza')) //Marilda dos S. P. de Souza
2638

2739
console.log(shortName('Marcos Ângelo Mateus dos Santos')) //Marcos A. M. dos Santos
2840
```
@@ -31,6 +43,8 @@ To run the test:
3143

3244
`npm run test`
3345

46+
`npm run test:**coverage**`
47+
3448
## Licence
3549

3650
This project is governed by the [MIT](/LICENSE.md). Just remember to be a nice person and send back any modifications, corrections or improvements. ✌️

dist/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default function shortName(fullName: string): string | undefined;
1+
export declare function shortName(fullName: string): string | undefined;

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.default = shortName;
3+
exports.shortName = shortName;
44
const PREPOSITIONS = ['de', 'do', 'dos', 'da', 'das', 'e'];
55
const normalized = (name) => {
66
return name.normalize("NFD")

eslint.config.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import tsParser from '@typescript-eslint/parser'
2+
import tsPlugin from '@typescript-eslint/eslint-plugin'
3+
import prettierPlugin from 'eslint-plugin-prettier'
4+
import eslintJs from '@eslint/js'
5+
import globals from 'globals'
6+
7+
export default [
8+
eslintJs.configs.recommended,
9+
{
10+
files: ['**/*.{ts,js}'],
11+
languageOptions: {
12+
parser: tsParser,
13+
ecmaVersion: 2021,
14+
sourceType: 'module',
15+
globals: {
16+
...globals.jest,
17+
},
18+
},
19+
plugins: {
20+
'@typescript-eslint': tsPlugin,
21+
prettier: prettierPlugin,
22+
},
23+
rules: {
24+
...tsPlugin.configs.recommended.rules,
25+
'prettier/prettier': 'error',
26+
'@typescript-eslint/explicit-function-return-type': 'warn',
27+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
28+
'no-console': ['error', { allow: ['warn', 'error'] }],
29+
'no-alert': 'error',
30+
'no-unreachable': 'error',
31+
},
32+
},
33+
{
34+
ignores: ['node_modules/**', 'dist/**', 'coverage/**', '**/*.d.ts'],
35+
},
36+
]

jest.config.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
module.exports = {
1+
export default {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
44
testMatch: ['**/tests/*.test.ts'],
5-
};
5+
transform: {
6+
'^.+\\.tsx?$': [
7+
'ts-jest',
8+
{
9+
useESM: true,
10+
},
11+
],
12+
},
13+
extensionsToTreatAsEsm: ['.ts'],
14+
moduleNameMapper: {
15+
'^(\\.{1,2}/.*)\\.js$': '$1',
16+
},
17+
}

0 commit comments

Comments
 (0)