init source
This commit is contained in:
+52
@@ -0,0 +1,52 @@
|
||||
# Change Log
|
||||
All notable changes to this resolver will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
|
||||
|
||||
## Unreleased
|
||||
|
||||
## v0.3.2 - 2018-01-05
|
||||
### Added
|
||||
- `.mjs` extension detected by default to support `experimental-modules` (#939)
|
||||
|
||||
### Deps
|
||||
- update `debug`, `resolve`
|
||||
|
||||
## v0.3.1 - 2017-06-23
|
||||
### Changed
|
||||
- bumped `debug` dep to match other packages
|
||||
|
||||
## v0.3.0 - 2016-12-15
|
||||
### Changed
|
||||
- bumped `resolve` to fix issues with Node builtins (thanks [@SkeLLLa] and [@ljharb])
|
||||
|
||||
### Fixed
|
||||
- use `files` in `package.json` to ship only `index.js` ([#531], thanks for noticing [@lukeapage])
|
||||
|
||||
## v0.2.3 - 2016-08-20
|
||||
### Added
|
||||
- debug logging (use `DEBUG=eslint-plugin-import:resolver:node eslint [...]`)
|
||||
|
||||
## v0.2.2 - 2016-07-14
|
||||
### Fixed
|
||||
- Node resolver no longer declares the import plugin as a `peerDependency`. See [#437]
|
||||
for a well-articulated and thoughtful expression of why this doesn't make sense.
|
||||
Thanks [@jasonkarns] for the issue and the PR to fix it ([#438]).
|
||||
|
||||
Also, apologies to the others who expressed this before, but I never understood
|
||||
what the problem was.😅
|
||||
|
||||
## v0.2.1
|
||||
### Fixed
|
||||
- find files with `.json` extensions (#333, thanks for noticing @jfmengels)
|
||||
|
||||
[#438]: https://github.com/benmosher/eslint-plugin-import/pull/438
|
||||
|
||||
[#939]: https://github.com/benmosher/eslint-plugin-import/issues/939
|
||||
[#531]: https://github.com/benmosher/eslint-plugin-import/issues/531
|
||||
[#437]: https://github.com/benmosher/eslint-plugin-import/issues/437
|
||||
|
||||
[@jasonkarns]: https://github.com/jasonkarns
|
||||
[@lukeapage]: https://github.com/lukeapage
|
||||
[@SkeLLLa]: https://github.com/SkeLLLa
|
||||
[@ljharb]: https://github.com/ljharb
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
# eslint-import-resolver-node
|
||||
|
||||
[](https://www.npmjs.com/package/eslint-import-resolver-node)
|
||||
|
||||
Default Node-style module resolution plugin for [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import).
|
||||
|
||||
Published separately to allow pegging to a specific version in case of breaking
|
||||
changes.
|
||||
|
||||
Config is passed directly through to [`resolve`](https://www.npmjs.com/package/resolve#resolve-sync-id-opts) as options:
|
||||
|
||||
```yaml
|
||||
settings:
|
||||
import/resolver:
|
||||
node:
|
||||
extensions:
|
||||
# if unset, default is just '.js', but it must be re-added explicitly if set
|
||||
- .js
|
||||
- .jsx
|
||||
- .es6
|
||||
- .coffee
|
||||
|
||||
paths:
|
||||
# an array of absolute paths which will also be searched
|
||||
# think NODE_PATH
|
||||
- /usr/local/share/global_modules
|
||||
|
||||
# this is technically for identifying `node_modules` alternate names
|
||||
moduleDirectory:
|
||||
|
||||
- node_modules # defaults to 'node_modules', but...
|
||||
- bower_components
|
||||
|
||||
- project/src # can add a path segment here that will act like
|
||||
# a source root, for in-project aliasing (i.e.
|
||||
# `import MyStore from 'stores/my-store'`)
|
||||
```
|
||||
|
||||
or to use the default options:
|
||||
|
||||
```yaml
|
||||
settings:
|
||||
import/resolver: node
|
||||
```
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
var resolve = require('resolve')
|
||||
, path = require('path')
|
||||
|
||||
var log = require('debug')('eslint-plugin-import:resolver:node')
|
||||
|
||||
exports.interfaceVersion = 2
|
||||
|
||||
exports.resolve = function (source, file, config) {
|
||||
log('Resolving:', source, 'from:', file)
|
||||
var resolvedPath
|
||||
|
||||
if (resolve.isCore(source)) {
|
||||
log('resolved to core')
|
||||
return { found: true, path: null }
|
||||
}
|
||||
|
||||
try {
|
||||
resolvedPath = resolve.sync(source, opts(file, config))
|
||||
log('Resolved to:', resolvedPath)
|
||||
return { found: true, path: resolvedPath }
|
||||
} catch (err) {
|
||||
log('resolve threw error:', err)
|
||||
return { found: false }
|
||||
}
|
||||
}
|
||||
|
||||
function opts(file, config) {
|
||||
return Object.assign({
|
||||
// more closely matches Node (#333)
|
||||
// plus 'mjs' for native modules! (#939)
|
||||
extensions: ['.mjs', '.js', '.json'],
|
||||
},
|
||||
config,
|
||||
{
|
||||
// path.resolve will handle paths relative to CWD
|
||||
basedir: path.dirname(path.resolve(file)),
|
||||
packageFilter: packageFilter,
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function packageFilter(pkg) {
|
||||
if (pkg['jsnext:main']) {
|
||||
pkg['main'] = pkg['jsnext:main']
|
||||
}
|
||||
return pkg
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"eslint-import-resolver-node@0.3.2",
|
||||
"/home/app"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "eslint-import-resolver-node@0.3.2",
|
||||
"_id": "eslint-import-resolver-node@0.3.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==",
|
||||
"_location": "/eslint-import-resolver-node",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "eslint-import-resolver-node@0.3.2",
|
||||
"name": "eslint-import-resolver-node",
|
||||
"escapedName": "eslint-import-resolver-node",
|
||||
"rawSpec": "0.3.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.3.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/eslint-plugin-import"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz",
|
||||
"_spec": "0.3.2",
|
||||
"_where": "/home/app",
|
||||
"author": {
|
||||
"name": "Ben Mosher",
|
||||
"url": "me@benmosher.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/benmosher/eslint-plugin-import/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "^2.6.9",
|
||||
"resolve": "^1.5.0"
|
||||
},
|
||||
"description": "Node default behavior import resolution plugin for eslint-plugin-import.",
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"mocha": "^3.5.3",
|
||||
"nyc": "^10.3.2"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/benmosher/eslint-plugin-import",
|
||||
"keywords": [
|
||||
"eslint",
|
||||
"eslintplugin",
|
||||
"esnext",
|
||||
"modules",
|
||||
"eslint-plugin-import"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "eslint-import-resolver-node",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/benmosher/eslint-plugin-import.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "nyc mocha"
|
||||
},
|
||||
"version": "0.3.2"
|
||||
}
|
||||
Reference in New Issue
Block a user