Skip to content

Commit

Permalink
fix: even if type is simple, when revival is async, throw if unexpect…
Browse files Browse the repository at this point in the history
…ed or convert to Promise

Also:
- refactor: TS work
- chore: update devDeps.
  • Loading branch information
brettz9 committed May 1, 2023
1 parent f32929a commit 8c1027d
Show file tree
Hide file tree
Showing 13 changed files with 1,944 additions and 630 deletions.
77 changes: 62 additions & 15 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
'use strict';

const mainRules = {
// Disable from recommended-requiring-type-checking (any)
'@typescript-eslint/no-unsafe-return': 0,
'@typescript-eslint/no-unsafe-argument': 0,
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/no-unsafe-call': 0,
// Disable from Strict
'@typescript-eslint/no-dynamic-delete': 0,
// Class Undefined has a use for us
'@typescript-eslint/no-extraneous-class': 0,

// Disable for now
'eslint-comments/require-description': 0,
'jsdoc/check-types': 0,

indent: ['error', 4, {outerIIFEBody: 0}],
'unicorn/consistent-destructuring': 0,
'promise/prefer-await-to-then': 0,
'promise/prefer-await-to-callbacks': 0,
'n/no-unsupported-features/es-builtins': 0,
'n/no-unsupported-features/es-syntax': 0,
'jsdoc/check-values': ['error', {allowedLicenses: true}],

'unicorn/no-this-assignment': 0,
'unicorn/prefer-spread': 0
};

const {readFileSync} = require('fs');

const tsconfig = JSON.parse(readFileSync('./tsconfig.json', 'utf8'));

module.exports = {
extends: 'ash-nazg/sauron-node-overrides',
extends: [
'ash-nazg/sauron-node-overrides'
],
parserOptions: {
ecmaVersion: 2022
},
settings: {
jsdoc: {
mode: 'typescript'
},
polyfills: [
'Array.from',
'Array.isArray',
Expand All @@ -27,11 +64,34 @@ module.exports = {
]
},
overrides: [
{
files: tsconfig.include,
extends: [
// 'plugin:@typescript-eslint/recommended',
// eslint-disable-next-line max-len -- Long
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
'ash-nazg/sauron-node-overrides'
],
parserOptions: {
project: true,
tsconfigRootDir: __dirname,
// Markdown problematic per https://github.com/typescript-eslint/typescript-eslint/issues/2373
extraFileExtensions: ['.html', '.md'],
ecmaVersion: 2022
},
rules: {
...mainRules
}
},
{
files: ['**/*.md/*.js'],
settings: {
polyfills: ['Float64Array', 'Int8Array']
},
parserOptions: {
project: null
},
rules: {
'eol-last': ['off'],
'no-console': ['off'],
Expand Down Expand Up @@ -69,19 +129,6 @@ module.exports = {
}
],
rules: {
// Disable for now
'eslint-comments/require-description': 0,
'jsdoc/check-types': 0,

indent: ['error', 4, {outerIIFEBody: 0}],
'unicorn/consistent-destructuring': 0,
'promise/prefer-await-to-then': 0,
'promise/prefer-await-to-callbacks': 0,
'n/no-unsupported-features/es-builtins': 0,
'n/no-unsupported-features/es-syntax': 0,
'jsdoc/check-values': ['error', {allowedLicenses: true}],

'unicorn/no-this-assignment': 0,
'unicorn/prefer-spread': 0
...mainRules
}
};
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"browser": "./dist/typeson.umd.js",
"module": "./dist/typeson.esm.js",
"type": "module",
"types": "./dist/typeson.d.ts",
"exports": {
".": {
"import": "./dist/typeson.esm.min.js",
Expand All @@ -14,17 +15,19 @@
}
},
"scripts": {
"tsc": "tsc",
"prepublishOnly": "pnpm i",
"eslint": "eslint --ext js,md,html .",
"lint": "npm run eslint --",
"start": "http-server -p 8092",
"rollup": "rollup -c",
"build": "npm run rollup && tsc -p tsconfig-build.json",
"open-test": "open-cli http://localhost:8092/test/ && npm start",
"browser-test": "npm run rollup && npm run eslint && npm run open-test",
"browser-test": "npm run build && npm run eslint && npm run open-test",
"open-coverage": "open-cli http://localhost:8092/coverage/ && npm start",
"mocha": "mocha --require chai/register-assert.js --require chai/register-expect.js test/test.js",
"mocha-cov": "rm -Rf node_modules/.cache && c8 --reporter=html --reporter=text npm run mocha",
"test": "npm run rollup && npm run eslint && npm run mocha-cov"
"test": "npm run build && npm run eslint && npm run mocha-cov"
},
"c8": {
"exclude": [
Expand Down Expand Up @@ -55,17 +58,21 @@
},
"homepage": "https://github.com/dfahlander/typeson#readme",
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
"node": ">=16.0.0"
},
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@brettz9/eslint-plugin": "^1.0.4",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-terser": "^0.4.1",
"@types/babel__core": "^7.20.0",
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@types/node": "^18.16.2",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"babel-plugin-transform-async-to-promises": "^0.8.18",
"base64-arraybuffer-es6": "^1.0.0",
"base64-arraybuffer-es6": "^2.0.1",
"c8": "^7.13.0",
"chai": "^4.3.7",
"eslint": "^8.39.0",
Expand All @@ -78,7 +85,7 @@
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^43.0.7",
"eslint-plugin-jsdoc": "^43.1.1",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-no-unsanitized": "^4.0.2",
Expand All @@ -91,8 +98,9 @@
"http-server": "^14.1.1",
"mocha": "^10.2.0",
"open-cli": "^7.2.0",
"rollup": "3.20.7",
"rollup-plugin-re": "^1.0.7"
"rollup": "3.21.0",
"rollup-plugin-re": "^1.0.7",
"typescript": "^5.0.4"
},
"tonicExample": "var Typeson = require('typeson');\nvar TSON = new Typeson().register(require('typeson-registry/presets/builtin'));\n\nTSON.stringify({foo: new Date()}, null, 2);"
}
Loading

0 comments on commit 8c1027d

Please sign in to comment.