-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: support
eslint@9
and flat config
- Loading branch information
1 parent
799968c
commit f20858c
Showing
20 changed files
with
574 additions
and
696 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/eslint-remote-tester/eslint-remote-tester.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import js from '@eslint/js'; | ||
import type { Config } from './src/types'; | ||
|
||
export default defineConfig({ | ||
repositories: [ | ||
'AriPerkkio/eslint-remote-tester-integration-test-target', | ||
'AriPerkkio/aria-live-capture', | ||
'AriPerkkio/extend-to-be-announced', | ||
'AriPerkkio/state-mgmt-examples', | ||
'AriPerkkio/suspense-examples', | ||
], | ||
|
||
extensions: ['js', 'jsx', 'ts', 'tsx'], | ||
|
||
maxFileSizeBytes: undefined, | ||
|
||
rulesUnderTesting: [], | ||
|
||
resultParser: undefined, | ||
|
||
concurrentTasks: 3, | ||
|
||
eslintConfig: [js.configs.recommended] as any, | ||
|
||
cache: true, | ||
|
||
compare: false, | ||
|
||
updateComparisonReference: true, | ||
|
||
onComplete: undefined, | ||
}); | ||
|
||
function defineConfig(config: Config) { | ||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
import { createRequire } from 'node:module'; | ||
import type { Service, RegisterOptions } from 'ts-node'; | ||
|
||
let registerer: Service | null = null; | ||
const require = createRequire(import.meta.url); | ||
|
||
/* istanbul ignore next */ | ||
const interopRequireDefault = (obj: any): { default: any } => | ||
obj && obj.__esModule ? obj : { default: obj }; | ||
|
||
/** @internal */ | ||
export const loadTSConfig = (configPath: string) => { | ||
export const loadTSConfig = async (configPath: string) => { | ||
let importx: typeof import('importx') | undefined = undefined; | ||
let jiti: typeof import('jiti') | undefined = undefined; | ||
|
||
try { | ||
registerer ||= require('ts-node').register({ | ||
moduleTypes: { '**/*.ts': 'cjs' }, | ||
} satisfies RegisterOptions) as Service; | ||
} catch (e: any) { | ||
if (e.code === 'MODULE_NOT_FOUND') { | ||
importx = await import('importx'); | ||
} catch { | ||
try { | ||
jiti = await import('jiti'); | ||
} catch { | ||
throw new Error( | ||
`'ts-node' is required for TypeScript configuration files. Make sure it is installed\nError: ${e.message}` | ||
"'jiti' or 'importx' is required for loading TypeScript configuration files. Make sure to install one of them." | ||
); | ||
} | ||
|
||
throw e; | ||
} | ||
|
||
registerer.enabled(true); | ||
|
||
const configObject = interopRequireDefault(require(configPath)).default; | ||
if (importx) { | ||
const config = await importx.import(configPath, import.meta.url); | ||
return config.default; | ||
} | ||
|
||
registerer.enabled(false); | ||
if (jiti) { | ||
return jiti.default(import.meta.url, { | ||
interopDefault: true, | ||
esmResolve: true, | ||
})(configPath); | ||
} | ||
|
||
return configObject; | ||
throw new Error( | ||
"'jiti' or 'importx' is required for loading TypeScript configuration files. Make sure to install one of them." | ||
); | ||
}; | ||
|
||
export const loadConfig = (configPath: string) => { | ||
export const loadConfig = async (configPath: string) => { | ||
if (configPath.endsWith('.ts')) { | ||
return loadTSConfig(configPath); | ||
} | ||
|
||
return require(configPath); | ||
const { default: config } = await import(configPath); | ||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.