forked from import-js/eslint-plugin-import
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
context
into resolver arguments
close import-js#2108
- Loading branch information
Showing
5 changed files
with
54 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
var path = require('path') | ||
|
||
exports.resolveImport = function (modulePath, sourceFile, config) { | ||
var sourceFileName = path.basename(sourceFile) | ||
if (sourceFileName === 'foo.js') { | ||
return path.join(__dirname, 'bar.jsx') | ||
} | ||
if (sourceFileName === 'exception.js') { | ||
throw new Error('foo-bar-resolver-v1 resolveImport test exception') | ||
} | ||
return undefined; | ||
} | ||
var assert = require('assert') | ||
var path = require('path') | ||
|
||
exports.resolveImport = function (modulePath, sourceFile, config, context) { | ||
var sourceFileName = path.basename(sourceFile) | ||
if (sourceFileName === 'foo.js') { | ||
return path.join(__dirname, 'bar.jsx') | ||
} | ||
if (sourceFileName === 'exception.js') { | ||
throw new Error('foo-bar-resolver-v1 resolveImport test exception') | ||
} | ||
assert.ok(context, 'the `context` must be presented') | ||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
var path = require('path') | ||
|
||
exports.resolveImport = function (modulePath, sourceFile, config) { | ||
var sourceFileName = path.basename(sourceFile) | ||
if (sourceFileName === 'foo.js') { | ||
return path.join(__dirname, 'bar.jsx'); | ||
} | ||
if (sourceFileName === 'exception.js') { | ||
throw new Error('foo-bar-resolver-v1 resolveImport test exception'); | ||
} | ||
return undefined; | ||
}; | ||
|
||
exports.interfaceVersion = 1; | ||
var assert = require('assert') | ||
var path = require('path') | ||
|
||
exports.resolveImport = function (modulePath, sourceFile, config, context) { | ||
var sourceFileName = path.basename(sourceFile) | ||
if (sourceFileName === 'foo.js') { | ||
return path.join(__dirname, 'bar.jsx'); | ||
} | ||
if (sourceFileName === 'exception.js') { | ||
throw new Error('foo-bar-resolver-v1 resolveImport test exception'); | ||
} | ||
assert.ok(context, 'the `context` must be presented') | ||
return undefined; | ||
}; | ||
|
||
exports.interfaceVersion = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
var path = require('path') | ||
|
||
exports.resolve = function (modulePath, sourceFile, config) { | ||
var sourceFileName = path.basename(sourceFile) | ||
if (sourceFileName === 'foo.js') { | ||
return { found: true, path: path.join(__dirname, 'bar.jsx') } | ||
} | ||
if (sourceFileName === 'exception.js') { | ||
throw new Error('foo-bar-resolver-v2 resolve test exception') | ||
} | ||
return { found: false }; | ||
}; | ||
|
||
exports.interfaceVersion = 2; | ||
var assert = require('assert') | ||
var path = require('path') | ||
|
||
exports.resolve = function (modulePath, sourceFile, config, context) { | ||
var sourceFileName = path.basename(sourceFile) | ||
if (sourceFileName === 'foo.js') { | ||
return { found: true, path: path.join(__dirname, 'bar.jsx') } | ||
} | ||
if (sourceFileName === 'exception.js') { | ||
throw new Error('foo-bar-resolver-v2 resolve test exception') | ||
} | ||
assert.ok(context, 'the `context` must be presented') | ||
return { found: false }; | ||
}; | ||
|
||
exports.interfaceVersion = 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters