mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Run TS eslint rules directly with strip-types
Wth node 20.18, we can now run these typescript files directly instead of having to use ts-node
This commit is contained in:
@@ -7,9 +7,9 @@ import * as eslint from 'eslint';
|
||||
import { TSESTree } from '@typescript-eslint/utils';
|
||||
import * as path from 'path';
|
||||
import minimatch from 'minimatch';
|
||||
import { createImportRuleListener } from './utils';
|
||||
import { createImportRuleListener } from './utils.ts';
|
||||
|
||||
const REPO_ROOT = path.normalize(path.join(__dirname, '../'));
|
||||
const REPO_ROOT = path.normalize(path.join(import.meta.dirname, '../'));
|
||||
|
||||
interface ConditionalPattern {
|
||||
when?: 'hasBrowser' | 'hasNode' | 'hasElectron' | 'test';
|
||||
@@ -31,7 +31,7 @@ interface LayerAllowRule {
|
||||
type RawOption = RawImportPatternsConfig | LayerAllowRule;
|
||||
|
||||
function isLayerAllowRule(option: RawOption): option is LayerAllowRule {
|
||||
return !!((<LayerAllowRule>option).when && (<LayerAllowRule>option).allow);
|
||||
return !!((option as LayerAllowRule).when && (option as LayerAllowRule).allow);
|
||||
}
|
||||
|
||||
interface ImportPatternsConfig {
|
||||
@@ -39,7 +39,7 @@ interface ImportPatternsConfig {
|
||||
restrictions: string[];
|
||||
}
|
||||
|
||||
export = new class implements eslint.Rule.RuleModule {
|
||||
export default new class implements eslint.Rule.RuleModule {
|
||||
|
||||
readonly meta: eslint.Rule.RuleMetaData = {
|
||||
messages: {
|
||||
@@ -55,7 +55,7 @@ export = new class implements eslint.Rule.RuleModule {
|
||||
};
|
||||
|
||||
create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {
|
||||
const options = <RawOption[]>context.options;
|
||||
const options = context.options as RawOption[];
|
||||
const configs = this._processOptions(options);
|
||||
const relativeFilename = getRelativeFilename(context);
|
||||
|
||||
@@ -217,7 +217,7 @@ export = new class implements eslint.Rule.RuleModule {
|
||||
configs.push(testConfig);
|
||||
}
|
||||
} else {
|
||||
configs.push({ target, restrictions: <string[]>restrictions.filter(r => typeof r === 'string') });
|
||||
configs.push({ target, restrictions: restrictions.filter(r => typeof r === 'string') as string[] });
|
||||
}
|
||||
}
|
||||
this._optionsCache.set(options, configs);
|
||||
|
||||
Reference in New Issue
Block a user