File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 33
44var path = require ( 'path' ) ;
55
6- var rules = requireUp ( 'eslint-local-rules.js' , __dirname ) ;
6+ var exts = [ 'js' , 'cjs' ] ;
7+ var rules = requireUp ( 'eslint-local-rules' , __dirname ) ;
78
89if ( ! rules ) {
910 throw new Error (
1011 'eslint-plugin-local-rules: ' +
11- 'Cannot find "eslint-local-rules.js" ' +
12+ 'Cannot find "eslint-local-rules.{' + exts . join ( ',' ) + "}" +
1213 '(looking up from "' + __dirname + '").'
1314 ) ;
1415}
@@ -23,12 +24,14 @@ module.exports = {
2324function requireUp ( filename , cwd ) {
2425 var filepath = path . resolve ( cwd , filename ) ;
2526
26- try {
27- return require ( filepath ) ;
28- } catch ( error ) {
29- // Ignore OS errors (will recurse to parent directory)
30- if ( error . code !== 'MODULE_NOT_FOUND' ) {
31- throw error ;
27+ for ( var i = 0 ; i < exts . length ; i ++ ) {
28+ try {
29+ return require ( filepath + '.' + exts [ i ] ) ;
30+ } catch ( error ) {
31+ // Ignore OS errors (will recurse to parent directory)
32+ if ( error . code !== 'MODULE_NOT_FOUND' ) {
33+ throw error ;
34+ }
3235 }
3336 }
3437
You can’t perform that action at this time.
0 commit comments