Skip to content

Commit

Permalink
feat: add createProgram
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Jul 30, 2024
1 parent f51fac9 commit 17427ab
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
12 changes: 8 additions & 4 deletions projects/eslint-plugin-experience/all.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const base =
projectJsonExist('tsconfig.eslint.json') || projectJsonExist('tsconfig.json') || '';
process.env.TYPESCRIPT_ESLINT_EXPERIMENTAL_TSSERVER = 'true';

/**
* @type {import('eslint').Linter.Config}
Expand Down Expand Up @@ -117,7 +116,12 @@ module.exports = {
ecmaVersion: 'latest',
errorOnTypeScriptSyntacticAndSemanticIssues: false,
errorOnUnknownASTType: true,
project: base ? [base] : [],
programs: [
require('@typescript-eslint/parser').createProgram(
projectJsonExist('tsconfig.eslint.json') ||
projectJsonExist('tsconfig.json'),
),
],
sourceType: 'module',
warnOnUnsupportedTypeScriptVersion: false,
},
Expand Down Expand Up @@ -1025,7 +1029,7 @@ function projectJsonExist(filename) {
try {
const path = require('node:path').resolve(filename);

return require('node:fs').existsSync(path) ? filename : undefined;
return require('node:fs').existsSync(path) ? path : undefined;
} catch {
return undefined;
}
Expand Down
21 changes: 0 additions & 21 deletions tsconfig.eslint.json

This file was deleted.

16 changes: 16 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "./projects/tsconfig/tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"strict": true,
"module": "ESNext",
"target": "ESNext",
"incremental": true,
"esModuleInterop": true,
"typeRoots": ["node_modules/@types"],
"types": ["node"]
},
"include": ["**/*.ts", "**/*.js"],
"exclude": ["**/node_modules"]
}

0 comments on commit 17427ab

Please sign in to comment.