diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dc3d1c6..42d2702 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -42,7 +42,7 @@ jobs: run: pnpm run type-check - name: Ensure all rules are in the README - run: NODE_OPTIONS="--require ts-node/register" pnpm exec markdownlint README.md docs/README.md --config tests/docs/.markdownlint.json --rules tests/docs/README.ts + run: NODE_OPTIONS="--require esbuild-runner/register" pnpm exec markdownlint README.md docs/README.md --config tests/docs/.markdownlint.json --rules tests/docs/README.ts - name: Ensure all rules are documented run: | @@ -61,7 +61,7 @@ jobs: fi - name: Ensure all rules are in the documentation sidebar - run: NODE_OPTIONS="--require ts-node/register" pnpm exec markdownlint docs/_sidebar.md --config tests/docs/.markdownlint.json --rules tests/docs/_sidebar.ts + run: NODE_OPTIONS="--require esbuild-runner/register" pnpm exec markdownlint docs/_sidebar.md --config tests/docs/.markdownlint.json --rules tests/docs/_sidebar.ts - name: Copy Documentation README run: ./.husky/pre-commit diff --git a/lib/utils/createValidator.ts b/lib/utils/createValidator.ts index d9fbc7e..4d5fe38 100644 --- a/lib/utils/createValidator.ts +++ b/lib/utils/createValidator.ts @@ -1,8 +1,8 @@ -import { ParsingResult, parse } from './parse'; -import type { JSONSchema4 } from 'json-schema'; -import type { SourceLocation } from 'acorn'; +import { ParsingResult, parse, type SourceLocation } from './parse'; import type { Rule } from 'eslint'; +type JSONSchema4 = Rule.RuleMetaData['schema']; + export type Metadata = { comment: { loc: SourceLocation; @@ -60,7 +60,7 @@ interface Options { /** * JSON Schema to validate attribute options */ - schema?: JSONSchema4 | JSONSchema4[]; + schema?: JSONSchema4; } interface OptionsRunOnce extends Options { @@ -293,7 +293,7 @@ export function createValidator({ } } - return {}; + return {} as Record; } } satisfies Rule.RuleModule; } diff --git a/lib/utils/parse.ts b/lib/utils/parse.ts index b6907cf..09e17ea 100644 --- a/lib/utils/parse.ts +++ b/lib/utils/parse.ts @@ -1,5 +1,4 @@ import type { SourceCode } from 'eslint'; -import type { SourceLocation } from 'acorn'; interface Line { value: string; @@ -10,6 +9,21 @@ interface Line { invalid: boolean; } +// Would import this from acorn, but tsup type resolution is broken + +export interface SourceLocation { + source?: string | null + start: Position + end: Position +} + +export interface Position { + /** 1-based */ + line: number + /** 0-based */ + column: number +} + export interface ParsingResult { /** * Whether the metadata has ended diff --git a/package.json b/package.json index 55605cc..941419c 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "@types/semver": "^7.5.6", "@typescript-eslint/eslint-plugin": "^6.17.0", "@typescript-eslint/parser": "^6.17.0", - "acorn": "^8.8.2", "esbuild": "^0.19.11", "esbuild-runner": "^2.2.2", "eslint": "8.56.0", @@ -40,15 +39,14 @@ "eslint-plugin-import": "^2.27.5", "eslint-plugin-unicorn": "^50.0.1", "husky": "^8.0.3", + "json-schema": "^0.4.0", "live-server": "^1.2.2", "markdownlint": "^0.32.1", "markdownlint-cli": "^0.38.0", "mocha": "^10.2.0", "nyc": "^15.1.0", "prettier": "^3.1.1", - "prettier-plugin-jsdoc": "^1.3.0", "should": "^13.2.3", - "ts-node": "^10.9.2", "tsup": "^8.0.1", "typescript": "^5.3.3" }, diff --git a/tsup.config.ts b/tsup.config.ts index 272a57a..9b6fac4 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -10,5 +10,12 @@ export default defineConfig({ platform: 'node', outDir: 'dist', bundle: false, - dts: true + dts: { + entry: [ + 'lib/utils/createValidator.ts', + 'lib/utils/parse.ts', + 'lib/index.ts' + ], + resolve: false + } });