Skip to content

Commit

Permalink
Refactor tsconfigs for perf and strictness
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed May 16, 2023
1 parent e69e55f commit f6bd64e
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 31 deletions.
11 changes: 6 additions & 5 deletions package.json
Expand Up @@ -11,10 +11,10 @@
},
"type": "module",
"workspaces": [
"packages/remark-parse",
"packages/remark-stringify",
"packages/remark",
"packages/remark-cli"
"packages/remark-parse/",
"packages/remark-stringify/",
"packages/remark/",
"packages/remark-cli/"
],
"devDependencies": {
"@types/mdast": "^3.0.0",
Expand All @@ -36,7 +36,8 @@
"xo": "^0.54.0"
},
"scripts": {
"build": "npm run build --workspaces && rimraf \"*.d.ts\" \"{test,script}/**/*.d.ts\" && tsc && type-coverage",
"prepack": "npm run build && npm run format",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "./packages/remark-cli/cli.js . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "npm run test --workspaces && node --conditions development test/index.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
Expand Down
1 change: 0 additions & 1 deletion packages/remark-cli/package.json
Expand Up @@ -35,7 +35,6 @@
"unified-args": "^10.0.0"
},
"scripts": {
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"test": "node --conditions development test.js"
},
"xo": false,
Expand Down
5 changes: 1 addition & 4 deletions packages/remark-cli/tsconfig.json
@@ -1,7 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["*.js"],
"compilerOptions": {
"resolveJsonModule": true
}
"references": [{"path": "../remark/"}]
}
2 changes: 1 addition & 1 deletion packages/remark-parse/index.d.ts
Expand Up @@ -3,7 +3,7 @@ import type {Root} from 'mdast'
import type {Plugin} from 'unified'
import type {Options} from './lib/index.js'

declare const remarkParse: Plugin<[Options?] | void[], string, Root>
declare const remarkParse: Plugin<[(Options | undefined)?], string, Root>
export default remarkParse

export type {Options} from './lib/index.js'
3 changes: 1 addition & 2 deletions packages/remark-parse/package.json
Expand Up @@ -46,8 +46,7 @@
"unified": "^10.0.0"
},
"scripts": {
"test": "node --conditions development test.js",
"build": "rimraf \"test.d.ts\" \"lib/**/*.d.ts\" && tsc && type-coverage"
"test": "node --conditions development test.js"
},
"xo": false,
"typeCoverage": {
Expand Down
3 changes: 1 addition & 2 deletions packages/remark-parse/tsconfig.json
@@ -1,4 +1,3 @@
{
"extends": "../../tsconfig.json",
"include": ["lib/**/*.js", "test.js"]
"extends": "../../tsconfig.json"
}
2 changes: 1 addition & 1 deletion packages/remark-stringify/index.d.ts
Expand Up @@ -3,7 +3,7 @@ import type {Root} from 'mdast'
import type {Plugin} from 'unified'
import type {Options} from './lib/index.js'

declare const remarkStringify: Plugin<[Options?] | void[], Root, string>
declare const remarkStringify: Plugin<[(Options | undefined)?], Root, string>
export default remarkStringify

export type {Options} from './lib/index.js'
2 changes: 1 addition & 1 deletion packages/remark-stringify/lib/index.js
Expand Up @@ -8,7 +8,7 @@ import {toMarkdown} from 'mdast-util-to-markdown'

/**
* @this {import('unified').Processor}
* @type {import('unified').Plugin<[Options]|void[], Node, string>}
* @type {import('unified').Plugin<[Options?]|void[], Node, string>}
*/
export default function remarkStringify(options) {
/** @type {import('unified').CompilerFunction<Node, string>} */
Expand Down
3 changes: 1 addition & 2 deletions packages/remark-stringify/package.json
Expand Up @@ -46,8 +46,7 @@
"unified": "^10.0.0"
},
"scripts": {
"test": "node --conditions development test.js",
"build": "rimraf \"test.d.ts\" \"lib/**/*.d.ts\" && tsc && type-coverage"
"test": "node --conditions development test.js"
},
"xo": false,
"typeCoverage": {
Expand Down
3 changes: 1 addition & 2 deletions packages/remark-stringify/tsconfig.json
@@ -1,4 +1,3 @@
{
"extends": "../../tsconfig.json",
"include": ["lib/**/*.js", "test.js"]
"extends": "../../tsconfig.json"
}
3 changes: 1 addition & 2 deletions packages/remark/package.json
Expand Up @@ -44,8 +44,7 @@
"unified": "^10.0.0"
},
"scripts": {
"test": "node --conditions development test.js",
"build": "rimraf \"*.d.ts\" && tsc && type-coverage"
"test": "node --conditions development test.js"
},
"xo": false,
"typeCoverage": {
Expand Down
2 changes: 1 addition & 1 deletion packages/remark/tsconfig.json
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["*.js"]
"references": [{"path": "../remark-parse/"}, {"path": "../remark-stringify/"}]
}
23 changes: 16 additions & 7 deletions tsconfig.json
@@ -1,13 +1,22 @@
{
"include": ["script/**/*.js", "test/**/*.js"],
"compilerOptions": {
"target": "es2021",
"lib": ["es2021"],
"module": "node16",
"customConditions": ["development"],
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"skipLibCheck": true,
"strict": true
}
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es2020"],
"module": "node16",
"newLine": "lf",
"resolveJsonModule": true,
"strict": true,
"target": "es2020"
},
"exclude": ["**/coverage/", "**/node_modules/"],
"include": [
"**/*.js",
"packages/remark-parse/index.d.ts",
"packages/remark-stringify/index.d.ts"
]
}

0 comments on commit f6bd64e

Please sign in to comment.