Skip to content

Commit

Permalink
Update tsconfig.json
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Feb 4, 2023
1 parent 8cabf32 commit 5d85347
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
31 changes: 17 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* @property {VFileOptions['extname']|SpecAffix} [extname]
* @property {VFileOptions['dirname']|SpecAffix} [dirname]
*
* @typedef {'path' | 'basename' | 'stem' | 'extname' | 'dirname'} SpecKey
*
* @typedef {(file: VFile) => VFile} Move
* When given something, returns a vfile from that, and changes its path
* properties.
Expand Down Expand Up @@ -98,11 +100,11 @@ export function convert(renames) {
* @returns {Move}
*/
function specFactory(spec) {
/** @type {Array<string>} */
/** @type {Array<SpecKey>} */
const props = []
/** @type {Array<Move>} */
const moves = []
/** @type {string} */
/** @type {SpecKey} */
let prop

// Fail on non-path props.
Expand All @@ -124,16 +126,17 @@ function specFactory(spec) {

while (++index < props.length) {
const prop = props[index]
const value = spec[prop]

if (typeof spec[prop] === 'string') {
moves.push(setter(prop, spec[prop]))
} else {
if (spec[prop].prefix) {
moves.push(prefix(prop, spec[prop].prefix))
if (typeof value === 'string') {
moves.push(setter(prop, value))
} else if (value) {
if ('prefix' in value && value.prefix) {
moves.push(prefix(prop, value.prefix))
}

if (spec[prop].suffix) {
moves.push(suffix(prop, spec[prop].suffix))
if ('suffix' in value && value.suffix) {
moves.push(suffix(prop, value.suffix))
}
}
}
Expand Down Expand Up @@ -181,16 +184,16 @@ function allFactory(changes) {
}

/**
* @param {string} a
* @param {string} b
* @param {SpecKey} a
* @param {SpecKey} b
* @returns {number}
*/
function sort(a, b) {
return order.indexOf(a) - order.indexOf(b)
}

/**
* @param {string} key
* @param {SpecKey} key
* @param {string} value
* @returns {Move}
*/
Expand All @@ -204,7 +207,7 @@ function setter(key, value) {
}

/**
* @param {string} key
* @param {SpecKey} key
* @param {string} prefix
* @returns {Move}
*/
Expand All @@ -218,7 +221,7 @@ function prefix(key, prefix) {
}

/**
* @param {string} key
* @param {SpecKey} key
* @param {string} suffix
* @returns {Move}
*/
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"prettier": "^2.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"to-vfile": "^7.0.0",
"type-coverage": "^2.0.0",
Expand All @@ -50,10 +49,10 @@
},
"scripts": {
"prepack": "npm run build && npm run format",
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
"prettier": {
Expand Down
18 changes: 10 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"include": ["*.js"],
"include": ["**/*.js"],
"exclude": ["coverage/", "node_modules/"],
"compilerOptions": {
"target": "ES2020",
"lib": ["ES2020"],
"module": "ES2020",
"moduleResolution": "node",
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
"exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es2020"],
"module": "node16",
"newLine": "lf",
"skipLibCheck": true,
"strict": true,
"target": "es2020"
}
}

0 comments on commit 5d85347

Please sign in to comment.