Skip to content

Commit 1e0f987

Browse files
authored
feat!: Port to TypeScript, closes #762 (#763)
Ports all code to Typescript. TS users should no longer need to install `@types/uuid`.
1 parent 1d532ca commit 1e0f987

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+6438
-7753
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
browserstack.err
33
dist/
44
local.log
5+
logs/
56
node_modules/
6-
vscode/

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"ms-vscode.vscode-typescript-next",
5+
"esbenp.prettier-vscode",
6+
"stkb.rewrap"
7+
]
8+
}

.vscode/tasks.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Build watcher",
6+
"group": "build",
7+
"type": "shell",
8+
"command": "npm run build:watch",
9+
"runOptions": {
10+
"runOn": "folderOpen"
11+
}
12+
},
13+
{
14+
"label": "Test watcher",
15+
"group": "build",
16+
"type": "shell",
17+
"command": "npm run test:watch",
18+
"windows": {
19+
"command": "npm run test:watch"
20+
},
21+
"presentation": {
22+
"reveal": "always",
23+
"panel": "new"
24+
},
25+
"runOptions": {
26+
"runOn": "folderOpen"
27+
}
28+
}
29+
]
30+
}

eslint.config.cjs eslint.config.mjs

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
const babelParser = require('@babel/eslint-parser');
2-
const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
3-
const globals = require('globals');
4-
const js = require('@eslint/js');
5-
const neostandard = require('neostandard')({ semi: true, noStyle: true });
1+
import js from '@eslint/js';
2+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
3+
import globals from 'globals';
4+
import neostandard from 'neostandard';
5+
import tseslint from 'typescript-eslint';
66

7-
module.exports = [
7+
const neostandardConfig = neostandard({ semi: true, noStyle: true });
8+
9+
export default [
810
js.configs.recommended,
9-
...neostandard,
11+
...tseslint.configs.recommended,
12+
...neostandardConfig,
1013
eslintPluginPrettierRecommended,
1114
{
1215
languageOptions: {
@@ -19,17 +22,20 @@ module.exports = [
1922
...globals.node,
2023
msCrypto: true,
2124
},
22-
parser: babelParser,
2325
},
2426
},
2527
{
2628
rules: {
29+
'@typescript-eslint/no-redeclare': 'error',
30+
'@typescript-eslint/no-require-imports': 'off',
31+
'no-redeclare': 'off',
2732
'no-var': ['error'],
2833
curly: ['error', 'all'],
2934
},
3035
},
3136
{
3237
ignores: [
38+
'eslint.config.cjs',
3339
'!.babelrc.js',
3440
'.local/',
3541
'**/dist/',

examples/benchmark/benchmark.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function benchmark(uuid, Benchmark) {
4545
.add('uuid.v1() fill existing array', function () {
4646
try {
4747
uuid.v1(null, array, 0);
48-
} catch (err) {
48+
} catch {
4949
// The spec (https://datatracker.ietf.org/doc/html/rfc9562#name-timestamp-considerations) defines that only 10M/s v1
5050
// UUIDs can be generated on a single node. This library throws an error if we hit that limit
5151
// (which can happen on modern hardware and modern Node.js versions).

examples/benchmark/package-lock.json

+48-44
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/browser-esmodules/example.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import pkg from 'uuid/package.json';
21
import * as uuid from './node_modules/uuid/dist/esm-browser/index.js';
32
import {
43
MAX as MAX_UUID,
@@ -16,6 +15,9 @@ import {
1615
v6ToV1 as uuidv6ToV1,
1716
v7 as uuidv7,
1817
} from './node_modules/uuid/dist/esm-browser/index.js';
18+
import pkg from './node_modules/uuid/package.json' with { type: 'json' };
19+
20+
console.log('pkg', pkg);
1921

2022
console.log('uuidv1()', uuidv1());
2123

examples/browser-esmodules/package-lock.json

+54-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)