File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -51,12 +51,24 @@ Object.keys(builtinRules).reduce((acc, cur) => {
5151
5252
5353// support 3rd-party plugins
54- // TODO: find a safer way, as this is no reliable(depends on the package manager)
55- // TODO: support scoped package. e.g. @typescript -eslint/eslint-plugin
54+ // TODO: find a safer way, as this is no reliable(depends on the package managers)
5655// TODO: lazy loading 3rd-party plugins
5756const root = findUp . sync ( "package.json" , { cwd : path . join ( __dirname , "../../" ) } ) ;
5857const mdir = path . join ( root , "../node_modules/" ) ;
59- const plugins = fs . readdirSync ( mdir ) . filter ( it => / ^ e s l i n t - p l u g i n / u. test ( it ) && it !== pkg . name ) ;
58+ const plugins = [ ] ;
59+
60+ const allModules = fs . readdirSync ( mdir ) ;
61+ const eslintPluginRegex = / ^ e s l i n t - p l u g i n / u;
62+
63+ // find eslint-plugin-xxx
64+ allModules . forEach ( it => eslintPluginRegex . test ( it ) && it !== pkg . name && plugins . push ( it ) ) ;
65+
66+ // find @foo /eslint-plugin-xxx
67+ allModules . filter ( it => it . startsWith ( "@" ) ) . forEach ( it => {
68+ const pkgs = fs . readdirSync ( path . join ( mdir , it ) ) ;
69+
70+ pkgs . forEach ( _pkg => eslintPluginRegex . test ( _pkg ) && plugins . push ( `${ it } /${ _pkg } ` ) ) ;
71+ } ) ;
6072
6173plugins . forEach ( it => {
6274 const plugin = require ( it ) ;
You can’t perform that action at this time.
0 commit comments