fileoverview import { HintContext , IHint } from 'hint' ; import { debug as d } from '@hint/utils-debug' ; import { Severity } from '@hint/utils-types' ; import { WebpackConfigEvents , WebpackConfigParse } from '@hint/parser-webpack-config' ; import { TypeScriptConfigEvents , TypeScriptConfigParse } from '@hint/parser-typescript-config' ; const debug = d ( __filename ) ; import meta from './meta/module-esnext-typescript' ; import { getMessage } from './i18n.import' ; export default class WebpackConfigModuleESNextTypescript implements IHint { public static readonly meta = meta ; public constructor ( context ) { let webpackEvent ; let typescriptEvent ; const webpackConfigReceived = ( webpackConfigEvent ) => { debug ( `'parse::end::webpack-config' received` ) ; webpackEvent = webpackConfigEvent ; } ; const typescriptConfigReceived = ( typescriptConfigEvent ) => { debug ( `'parse::end::typescript-config' received` ) ; typescriptEvent = typescriptConfigEvent ; } ; const validate = ( ) => { if ( ! webpackEvent ) { debug ( `no 'parse::end::webpack-config' received` ) ; return ; } if ( ! typescriptEvent ) { debug ( `no 'parse::end::typescript-config' received` ) ; return ; } const version = parseInt ( webpackEvent . version ) ; if ( version < 2 ) { return ; } if ( typescriptEvent . config . compilerOptions && ( typescriptEvent . config . compilerOptions . module as any ) . toLowerCase ( ) !== 'esnext' ) { context . report ( typescriptEvent . resource , getMessage ( 'esnext' , context . language ) , { severity : Severity . error } ) ; } } ; context . on ( 'parse::end::webpack-config' , webpackConfigReceived ) ; context . on ( 'parse::end::typescript-config' , typescriptConfigReceived ) ; context . on ( 'scan::end' , validate ) ; } }