Skip to content

Commit

Permalink
Update code style
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed May 21, 2024
1 parent 086f58a commit 0fe32e4
Show file tree
Hide file tree
Showing 10 changed files with 1,902 additions and 1,377 deletions.
4 changes: 2 additions & 2 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pico from 'picocolors'

import { showVersion } from './show-version.js'
import { showHelp } from './show-help.js'
import { check } from './check.js'
import { showHelp } from './show-help.js'
import { showVersion } from './show-version.js'

function error(message) {
process.stderr.write(pico.red(message) + '\n')
Expand Down
24 changes: 12 additions & 12 deletions check.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { dirname, basename, join, relative } from 'path'
import { promises as fs } from 'fs'
import { createRequire } from 'module'
import { fileURLToPath } from 'url'
import glob from 'fast-glob'
import { createSpinner } from 'nanospinner'
import { location } from 'vfile-location'
import { Worker } from 'worker_threads'
import { promises as fs } from 'node:fs'
import { createRequire } from 'node:module'
import { basename, dirname, join, relative } from 'node:path'
import { fileURLToPath } from 'node:url'
import { Worker } from 'node:worker_threads'
import pico from 'picocolors'
import glob from 'fast-glob'
import { location } from 'vfile-location'

import { getCompilerOptions } from './get-compiler-options.js'

Expand All @@ -24,7 +24,7 @@ const PREFIX = '// THROWS '
function checkFiles(files, compilerOptions) {
return new Promise((resolve, reject) => {
let worker = new Worker(WORKER, {
workerData: { files, compilerOptions }
workerData: { compilerOptions, files }
})
worker.on('message', resolve)
worker.on('error', reject)
Expand Down Expand Up @@ -57,8 +57,8 @@ async function parseTest(files) {
if (newline !== -1) newline += pos

let pattern = source.slice(pos + PREFIX.length, newline)
let { line, column } = lines.toPoint(pos)
expects.push({ fileName, line: line + 1, column, pattern })
let { column, line } = lines.toPoint(pos)
expects.push({ column, fileName, line: line + 1, pattern })
prev = pos
}
})
Expand All @@ -77,7 +77,7 @@ export async function check(

let compilerOptions = getCompilerOptions(cwd)

let all = await glob(globs, { cwd, ignore: ['node_modules'], absolute: true })
let all = await glob(globs, { absolute: true, cwd, ignore: ['node_modules'] })

if (!all.some(i => /\.tsx?$/.test(i))) {
let err = new Error(
Expand Down Expand Up @@ -117,7 +117,7 @@ export async function check(
continue
}

let { line, column } = location(error.file.text).toPoint(error.start)
let { column, line } = location(error.file.text).toPoint(error.start)
let expect = expects.find(j => {
return error.file.fileName === j.fileName && line === j.line && !j.used
})
Expand Down
4 changes: 2 additions & 2 deletions create-program.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createRequire } from 'node:module'
import { dirname, join } from 'node:path'
import ts from 'typescript'
import { createRequire } from 'module'
import { dirname, join } from 'path'

let require = createRequire(import.meta.url)

Expand Down
14 changes: 14 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import loguxTsConfig from '@logux/eslint-config'

export default [
...loguxTsConfig,
{
files: ['test/**/*.test.js'],
languageOptions: {
globals: {
expect: 'readonly',
it: 'readonly'
}
}
}
]
16 changes: 8 additions & 8 deletions get-compiler-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import ts from 'typescript'

const DEFAULT_OPTIONS = ts.convertCompilerOptionsFromJson(
{
allowJs: true,
allowSyntheticDefaultImports: true,
strictFunctionTypes: false,
noUnusedParameters: true,
noImplicitReturns: true,
jsx: 'react',
module: 'esnext',
moduleResolution: 'NodeJs',
noEmit: true,
noImplicitReturns: true,
noUnusedLocals: true,
stripInternal: true,
allowJs: true,
module: 'esnext',
noUnusedParameters: true,
strict: true,
noEmit: true,
jsx: 'react'
strictFunctionTypes: false,
stripInternal: true
},
'./'
).options
Expand Down
33 changes: 9 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,22 @@
"typescript": ">=4.0.0"
},
"dependencies": {
"fast-glob": "^3.2.12",
"fast-glob": "^3.3.2",
"nanospinner": "^1.1.0",
"picocolors": "^1.0.0",
"vfile-location": "^4.1.0"
"picocolors": "^1.0.1",
"vfile-location": "^5.0.2"
},
"author": "Andrey Sitnik <andrey@sitnik.ru>",
"license": "MIT",
"repository": "ai/check-dts",
"devDependencies": {
"@babel/core": "^7.21.5",
"@logux/eslint-config": "^49.0.0",
"clean-publish": "^4.2.0",
"eslint": "^8.39.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prefer-let": "^3.0.1",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.5.0",
"@babel/core": "^7.24.5",
"@logux/eslint-config": "^53.2.0",
"clean-publish": "^4.4.0",
"eslint": "^9.3.0",
"jest": "^29.7.0",
"print-snapshots": "^0.4.2",
"typescript": "^5.0.4"
},
"eslintConfig": {
"extends": "@logux/eslint-config",
"rules": {
"n/global-require": "off"
},
"globals": {
"expect": "readonly",
"it": "readonly"
}
"typescript": "^5.4.5"
},
"jest": {
"testEnvironment": "node",
Expand Down

0 comments on commit 0fe32e4

Please sign in to comment.