Skip to content

Commit

Permalink
perf: trim down on typescript defs and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash-Singh1 committed Jan 4, 2024
1 parent 530ecc4 commit 6c745bc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions lib/utils/createValidator.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -60,7 +60,7 @@ interface Options {
/**
* JSON Schema to validate attribute options
*/
schema?: JSONSchema4 | JSONSchema4[];
schema?: JSONSchema4;
}

interface OptionsRunOnce extends Options {
Expand Down Expand Up @@ -293,7 +293,7 @@ export function createValidator({
}
}

return {};
return {} as Record<string, never>;
}
} satisfies Rule.RuleModule;
}
16 changes: 15 additions & 1 deletion lib/utils/parse.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { SourceCode } from 'eslint';
import type { SourceLocation } from 'acorn';

interface Line {
value: string;
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
9 changes: 8 additions & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
});

0 comments on commit 6c745bc

Please sign in to comment.