Skip to content

Commit

Permalink
feat!: Port to TypeScript, closes #762 (#763)
Browse files Browse the repository at this point in the history
Ports all code to Typescript.  TS users should no longer need to install `@types/uuid`.
  • Loading branch information
broofa authored Jul 16, 2024
1 parent 1d532ca commit 1e0f987
Show file tree
Hide file tree
Showing 73 changed files with 6,438 additions and 7,753 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
browserstack.err
dist/
local.log
logs/
node_modules/
vscode/
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"ms-vscode.vscode-typescript-next",
"esbenp.prettier-vscode",
"stkb.rewrap"
]
}
30 changes: 30 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build watcher",
"group": "build",
"type": "shell",
"command": "npm run build:watch",
"runOptions": {
"runOn": "folderOpen"
}
},
{
"label": "Test watcher",
"group": "build",
"type": "shell",
"command": "npm run test:watch",
"windows": {
"command": "npm run test:watch"
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}
22 changes: 14 additions & 8 deletions eslint.config.cjs → eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const babelParser = require('@babel/eslint-parser');
const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
const globals = require('globals');
const js = require('@eslint/js');
const neostandard = require('neostandard')({ semi: true, noStyle: true });
import js from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import neostandard from 'neostandard';
import tseslint from 'typescript-eslint';

module.exports = [
const neostandardConfig = neostandard({ semi: true, noStyle: true });

export default [
js.configs.recommended,
...neostandard,
...tseslint.configs.recommended,
...neostandardConfig,
eslintPluginPrettierRecommended,
{
languageOptions: {
Expand All @@ -19,17 +22,20 @@ module.exports = [
...globals.node,
msCrypto: true,
},
parser: babelParser,
},
},
{
rules: {
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-require-imports': 'off',
'no-redeclare': 'off',
'no-var': ['error'],
curly: ['error', 'all'],
},
},
{
ignores: [
'eslint.config.cjs',
'!.babelrc.js',
'.local/',
'**/dist/',
Expand Down
2 changes: 1 addition & 1 deletion examples/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function benchmark(uuid, Benchmark) {
.add('uuid.v1() fill existing array', function () {
try {
uuid.v1(null, array, 0);
} catch (err) {
} catch {
// The spec (https://datatracker.ietf.org/doc/html/rfc9562#name-timestamp-considerations) defines that only 10M/s v1
// UUIDs can be generated on a single node. This library throws an error if we hit that limit
// (which can happen on modern hardware and modern Node.js versions).
Expand Down
92 changes: 48 additions & 44 deletions examples/benchmark/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion examples/browser-esmodules/example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pkg from 'uuid/package.json';
import * as uuid from './node_modules/uuid/dist/esm-browser/index.js';
import {
MAX as MAX_UUID,
Expand All @@ -16,6 +15,9 @@ import {
v6ToV1 as uuidv6ToV1,
v7 as uuidv7,
} from './node_modules/uuid/dist/esm-browser/index.js';
import pkg from './node_modules/uuid/package.json' with { type: 'json' };

console.log('pkg', pkg);

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

Expand Down
102 changes: 54 additions & 48 deletions examples/browser-esmodules/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1e0f987

Please sign in to comment.