fileoverview import { debug as d } from '@hint/utils-debug' ; import { HintContext , IHint } from 'hint' ; import { Severity } from '@hint/utils-types' ; import { BabelConfigEvents , BabelConfigExtendsError , BabelConfigInvalidJSON , BabelConfigInvalidSchema } from '@hint/parser-babel-config' ; import meta from './meta/is-valid' ; const debug = d ( __filename ) ; export default class BabelConfigIsValidHint implements IHint { public static readonly meta = meta ; public constructor ( context ) { const invalidJSONFile = ( babelConfigInvalid , event ) => { const { error , resource } = babelConfigInvalid ; debug ( `${ event } received` ) ; context . report ( resource , error . message , { severity : Severity . error } ) ; } ; const invalidExtends = ( babelConfigInvalid , event ) => { const { error , resource , getLocation } = babelConfigInvalid ; debug ( `${ event } received` ) ; context . report ( resource , error . message , { location : getLocation ( 'extends' , { at : 'value' } ) , severity : Severity . error } ) ; } ; const invalidSchema = ( fetchEnd ) => { const { groupedErrors , resource } = fetchEnd ; debug ( `'parse::error::babel-config::schema' received` ) ; for ( let i = 0 ; i < groupedErrors . length ; i ++ ) { const groupedError = groupedErrors [ i ] ; context . report ( resource , groupedError . message , { location : groupedError . location , severity : Severity . error } ) ; } } ; context . on ( 'parse::error::babel-config::json' , invalidJSONFile ) ; context . on ( 'parse::error::babel-config::extends' , invalidExtends ) ; context . on ( 'parse::error::babel-config::schema' , invalidSchema ) ; } }