diff --git a/.circleci/config.yml b/.circleci/config.yml index 5327e18..32d1243 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ orbs: parameters: node_version: type: string - default: '16.15.0' + default: '16.17.0' commands: install_deps: @@ -15,7 +15,9 @@ commands: pkg-manager: yarn cache-version: v1-all app-dir: ~/repo - override-ci-command: yarn install --pure-lockfile --ignore-scripts --no-progress + override-ci-command: > + npx --yes retry-cli -n 5 -t 3000 -- + yarn install --pure-lockfile --ignore-scripts --no-progress jobs: build: @@ -26,6 +28,6 @@ jobs: steps: - checkout - install_deps - - run: yarn test --maxWorkers=4 - run: yarn type-check - run: yarn lint:ci + - run: yarn coverage --maxWorkers=4 diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 0000000..599a668 --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,18 @@ +import type {Config} from 'jest'; + +const config: Config = { + transform: { + '^.+\\.(t|j)sx?$': '@swc/jest', + }, + resetMocks: true, + coverageThreshold: { + global: { + branches: 100, + functions: 100, + lines: 100, + statements: 100, + }, + }, +}; + +export default config; diff --git a/package.json b/package.json index 70c9c18..1b9a426 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,10 @@ "email": "vlad@shelf.io", "url": "https://shelf.io" }, - "main": "lib", + "sideEffects": false, + "type": "module", + "exports": "./lib/index.js", + "main": "lib/index.js", "types": "lib/index.d.ts", "files": [ "lib" @@ -16,9 +19,7 @@ "scripts": { "benchmark:memory": "yarn build && cd benchmark/memory && ./test.sh", "benchmark:speed": "yarn build && cd benchmark/speed && babel test.ts | node", - "build": "rm -rf lib/ && yarn build:types && yarn build:code", - "build:code": "babel src --out-dir lib --ignore '**/*.test.ts' --extensions '.ts' && find ./lib -name '*.test.d.ts' -delete", - "build:types": "tsc --emitDeclarationOnly --declaration --isolatedModules false --declarationDir lib", + "build": "rm -rf lib/ && tsc", "coverage": "yarn test --coverage", "lint": "yarn lint:ci --fix", "lint:ci": "eslint . --ext .js,.ts,.json", @@ -35,17 +36,13 @@ "eslint --fix" ] }, - "babel": { - "extends": "@shelf/babel-config/backend" - }, "prettier": "@shelf/prettier-config", "devDependencies": { - "@babel/cli": "7.22.5", - "@babel/core": "7.22.5", - "@shelf/babel-config": "1.2.0", "@shelf/eslint-config": "2.27.1", "@shelf/prettier-config": "1.0.0", "@shelf/tsconfig": "0.0.11", + "@swc/core": "1.3.73", + "@swc/jest": "0.2.27", "@types/jest": "29.4.0", "@types/node": "14", "benny": "3.7.1", @@ -56,6 +53,7 @@ "lint-staged": "13.2.2", "normalize-space-x": "4.1.2", "prettier": "2.8.8", + "ts-node": "10.9.1", "typescript": "5.1.3" }, "engines": { diff --git a/src/index.test.ts b/src/index.test.ts index 51f2209..7a9e799 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -15,6 +15,12 @@ describe('#normalizeSpaces', () => { expect(result).toEqual('a b'); }); + it('should normalize text without spaces at the start and at the end correctly', () => { + const result = normalizeSpaces(`a${ALL_WHITESPACE_CHARS_2018}b`); + + expect(result).toEqual('a b'); + }); + it('should normalize text with character that consists of surrogate pairs correctly', () => { const result = normalizeSpaces(' hello \n\n\n interesting \n \n \tworld 😀 '); diff --git a/tsconfig.json b/tsconfig.json index 5bbaf96..6ab995e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,14 @@ { "extends": "@shelf/tsconfig/backend", "compilerOptions": { - "strict": true + "strict": true, + "module": "ESNext", + "target": "ESNext", + "moduleResolution": "node", + "declaration": true, + "resolveJsonModule": false, + "outDir": "lib" }, - "exclude": ["node_modules"], + "exclude": ["node_modules", "**/*.test.*", "**/*.mock.ts"], "include": ["src"] }