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 3
3
4
4
var path = require ( 'path' ) ;
5
5
6
- var rules = requireUp ( 'eslint-local-rules.js' , __dirname ) ;
6
+ var exts = [ 'js' , 'cjs' ] ;
7
+ var rules = requireUp ( 'eslint-local-rules' , __dirname ) ;
7
8
8
9
if ( ! rules ) {
9
10
throw new Error (
10
11
'eslint-plugin-local-rules: ' +
11
- 'Cannot find "eslint-local-rules.js" ' +
12
+ 'Cannot find "eslint-local-rules.{' + exts . join ( ',' ) + "}" +
12
13
'(looking up from "' + __dirname + '").'
13
14
) ;
14
15
}
@@ -23,12 +24,14 @@ module.exports = {
23
24
function requireUp ( filename , cwd ) {
24
25
var filepath = path . resolve ( cwd , filename ) ;
25
26
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
+ }
32
35
}
33
36
}
34
37
You can’t perform that action at this time.
0 commit comments