Skip to content

Commit

Permalink
Merge branch 'master' into no-relative-parent-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed May 17, 2018
2 parents dd0520e + 8f668c7 commit 2e05c3f
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 36 deletions.
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]
- Add [`no-relative-parent-imports`] rule: disallow relative imports from parent directories.

## [2.12.0] - 2018-05-17
### Added
- Ignore type imports for [`named`] rule ([#931], thanks [@mattijsbliek])
- Add documentation for [`no-useless-path-segments`] rule ([#1068], thanks [@manovotny])
- Add [`no-relative-parent-imports`] rule: disallow relative imports from parent directories.

- `packageDir` option for [`no-extraneous-dependencies`] can be array-valued ([#1085], thanks [@hulkish])

# [2.11.0] - 2018-04-09
## [2.11.0] - 2018-04-09
### Added
- Fixer for [`first`] ([#1046], thanks [@fengkfengk])
- `allow-require` option for [`no-commonjs`] rule ([#880], thanks [@futpib])
Expand Down Expand Up @@ -464,6 +466,7 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#1085]: https://github.com/benmosher/eslint-plugin-import/pull/1085
[#1068]: https://github.com/benmosher/eslint-plugin-import/pull/1068
[#1046]: https://github.com/benmosher/eslint-plugin-import/pull/1046
[#944]: https://github.com/benmosher/eslint-plugin-import/pull/944
Expand Down Expand Up @@ -607,7 +610,8 @@ for info on changes for earlier releases.
[#119]: https://github.com/benmosher/eslint-plugin-import/issues/119
[#89]: https://github.com/benmosher/eslint-plugin-import/issues/89

[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.11.0...HEAD
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.12.0...HEAD
[2.12.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.11.0...v2.12.0
[2.11.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.10.0...v2.11.0
[2.10.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.9.0...v2.10.0
[2.9.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.8.0...v2.9.0
Expand Down Expand Up @@ -717,3 +721,4 @@ for info on changes for earlier releases.
[@lukeapage]: https://github.com/lukeapage
[@manovotny]: https://github.com/manovotny
[@mattijsbliek]: https://github.com/mattijsbliek
[@hulkish]: https://github.com/hulkish
28 changes: 13 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-import",
"version": "2.11.0",
"version": "2.12.0",
"description": "Import with sanity.",
"engines": {
"node": ">=4"
Expand All @@ -16,15 +16,11 @@
],
"scripts": {
"watch": "cross-env NODE_PATH=./src mocha --watch --compilers js:babel-register --recursive tests/src",
"cover": "gulp pretest && cross-env NODE_PATH=./lib istanbul cover --dir reports/coverage _mocha tests/lib/ -- --recursive -R progress",
"pretest": "linklocal",
"posttest": "eslint ./src",
"test": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot --recursive tests/src -t 5s",
"test-compiled": "npm run prepublish && NODE_PATH=./lib mocha --compilers js:babel-register --recursive tests/src",
"coverage-report": "npm t && nyc report --reporter html",
"test-all": "npm test && for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done",
"ci-test": "eslint ./src && gulp pretest && cross-env NODE_PATH=./lib istanbul cover --report lcovonly --dir reports/coverage _mocha tests/lib/ -- --recursive --reporter dot",
"debug": "cross-env NODE_PATH=./lib mocha debug --recursive --reporter dot tests/lib/",
"prepublish": "gulp prepublish",
"coveralls": "nyc report --reporter lcovonly && cat ./coverage/lcov.info | coveralls"
},
Expand All @@ -48,12 +44,12 @@
},
"homepage": "https://github.com/benmosher/eslint-plugin-import",
"devDependencies": {
"babel-eslint": "next",
"babel-plugin-istanbul": "^2.0.1",
"babel-eslint": "8.0.x",
"babel-plugin-istanbul": "^4.1.6",
"babel-preset-es2015-argon": "latest",
"babel-register": "6.24.1",
"babel-register": "^6.26.0",
"babylon": "6.15.0",
"chai": "^3.4.0",
"chai": "^3.5.0",
"coveralls": "^3.0.0",
"cross-env": "^4.0.0",
"eslint": "2.x - 4.x",
Expand All @@ -62,18 +58,16 @@
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
"eslint-module-utils": "file:./utils",
"eslint-plugin-import": "2.x",
"eslint-plugin-typescript": "^0.8.1",
"gulp": "^3.9.0",
"gulp-babel": "6.1.2",
"istanbul": "^0.4.0",
"linklocal": "^2.6.0",
"mocha": "^3.1.2",
"nyc": "^8.3.0",
"mocha": "^3.5.3",
"nyc": "^11.7.1",
"redux": "^3.0.4",
"rimraf": "^2.6.2",
"sinon": "^2.3.2",
"typescript": "^2.6.2",
"typescript-eslint-parser": "^12.0.0"
"typescript-eslint-parser": "^15.0.0"
},
"peerDependencies": {
"eslint": "2.x - 4.x"
Expand All @@ -95,6 +89,10 @@
"babel-register"
],
"sourceMap": false,
"instrument": false
"instrument": false,
"include": [
"src/",
"resolvers/"
]
}
}
11 changes: 9 additions & 2 deletions resolvers/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"index.js"
],
"scripts": {
"test": "nyc mocha"
"test": "nyc mocha",
"coveralls": "nyc report --reporter lcovonly && cd ../.. && coveralls < ./resolvers/node/coverage/lcov.info"
},
"repository": {
"type": "git",
Expand All @@ -32,7 +33,13 @@
},
"devDependencies": {
"chai": "^3.5.0",
"coveralls": "^3.0.0",
"mocha": "^3.5.3",
"nyc": "^10.3.2"
"nyc": "^11.7.1"
},
"nyc": {
"exclude": [
"test/"
]
}
}
6 changes: 6 additions & 0 deletions resolvers/webpack/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
## Unreleased


## 0.10.0 - 2018-05-17
### Changed
- cache webpack resolve function, for performance ([#788]/[#1091])

## 0.9.0 - 2018-03-29
### Breaking
- Fix with `pnpm` by bumping `resolve` ([#968])
Expand Down Expand Up @@ -97,6 +101,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
- `interpret` configs (such as `.babel.js`).
Thanks to [@gausie] for the initial PR ([#164], ages ago! 😅) and [@jquense] for tests ([#278]).

[#1091]: https://github.com/benmosher/eslint-plugin-import/pull/1091
[#969]: https://github.com/benmosher/eslint-plugin-import/pull/969
[#968]: https://github.com/benmosher/eslint-plugin-import/pull/968
[#683]: https://github.com/benmosher/eslint-plugin-import/pull/683
Expand All @@ -112,6 +117,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
[#181]: https://github.com/benmosher/eslint-plugin-import/pull/181
[#164]: https://github.com/benmosher/eslint-plugin-import/pull/164

[#788]: https://github.com/benmosher/eslint-plugin-import/issues/788
[#681]: https://github.com/benmosher/eslint-plugin-import/issues/681
[#435]: https://github.com/benmosher/eslint-plugin-import/issues/435
[#411]: https://github.com/benmosher/eslint-plugin-import/issues/411
Expand Down
30 changes: 24 additions & 6 deletions resolvers/webpack/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
var findRoot = require('find-root')
, path = require('path')
, get = require('lodash.get')
, get = require('lodash/get')
, isEqual = require('lodash/isEqual')
, find = require('array-find')
, interpret = require('interpret')
// not available on 0.10.x
, isAbsolute = path.isAbsolute || require('is-absolute')
, fs = require('fs')
, coreLibs = require('node-libs-browser')
, resolve = require('resolve')
Expand Down Expand Up @@ -56,7 +55,7 @@ exports.resolve = function (source, file, settings) {
if (!configPath || typeof configPath === 'string') {

// see if we've got an absolute path
if (!configPath || !isAbsolute(configPath)) {
if (!configPath || !path.isAbsolute(configPath)) {
// if not, find ancestral package.json and use its directory as base for the path
packageDir = findRoot(path.resolve(file))
if (!packageDir) throw new Error('package not found above ' + file)
Expand Down Expand Up @@ -105,7 +104,8 @@ exports.resolve = function (source, file, settings) {
}

// otherwise, resolve "normally"
var resolveSync = createResolveSync(configPath, webpackConfig)
var resolveSync = getResolveSync(configPath, webpackConfig)

try {
return { found: true, path: resolveSync(path.dirname(file), source) }
} catch (err) {
Expand All @@ -114,6 +114,24 @@ exports.resolve = function (source, file, settings) {
}
}

var MAX_CACHE = 10
var _cache = []
function getResolveSync(configPath, webpackConfig) {
var cacheKey = { configPath: configPath, webpackConfig: webpackConfig }
var cached = find(_cache, function (entry) { return isEqual(entry.key, cacheKey) })
if (!cached) {
cached = {
key: cacheKey,
value: createResolveSync(configPath, webpackConfig)
}
// put in front and pop last item
if (_cache.unshift(cached) > MAX_CACHE) {
_cache.pop()
}
}
return cached.value
}

function createResolveSync(configPath, webpackConfig) {
var webpackRequire
, basedir = null
Expand Down Expand Up @@ -316,7 +334,7 @@ function findConfigPath(configPath, packageDir) {
})

// see if we've got an absolute path
if (!isAbsolute(configPath)) {
if (!path.isAbsolute(configPath)) {
configPath = path.join(packageDir, configPath)
}
} else {
Expand Down
24 changes: 15 additions & 9 deletions resolvers/webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "eslint-import-resolver-webpack",
"version": "0.9.0",
"version": "0.10.0",
"description": "Resolve paths to dependencies, given a webpack.config.js. Plugin for eslint-plugin-import.",
"main": "index.js",
"scripts": {
"test": "nyc mocha -t 5s",
"report": "nyc report --reporter=html"
"report": "nyc report --reporter=html",
"coveralls": "nyc report --reporter lcovonly && cd ../.. && coveralls < ./resolvers/webpack/coverage/lcov.info"
},
"files": [
"index.js",
Expand Down Expand Up @@ -35,8 +36,7 @@
"find-root": "^1.1.0",
"has": "^1.0.1",
"interpret": "^1.0.0",
"is-absolute": "^0.2.3",
"lodash.get": "^4.4.2",
"lodash": "^4.17.4",
"node-libs-browser": "^1.0.0 || ^2.0.0",
"resolve": "^1.4.0",
"semver": "^5.3.0"
Expand All @@ -46,11 +46,17 @@
"webpack": ">=1.11.0"
},
"devDependencies": {
"babel-plugin-istanbul": "^4.1.5",
"babel-preset-es2015-argon": "^0.1.0",
"babel-plugin-istanbul": "^4.1.6",
"babel-preset-es2015-argon": "latest",
"babel-register": "^6.26.0",
"chai": "^3.4.1",
"mocha": "^2.3.3",
"nyc": "^7.0.0"
"chai": "^3.5.0",
"coveralls": "^3.0.0",
"mocha": "^3.5.3",
"nyc": "^11.7.1"
},
"nyc": {
"exclude": [
"test/"
]
}
}
2 changes: 2 additions & 0 deletions tests/src/core/getExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ describe('ExportMap', function () {
})

context('alternate parsers', function () {

const configs = [
// ['string form', { 'typescript-eslint-parser': '.ts' }],
['array form', { 'typescript-eslint-parser': ['.ts', '.tsx'] }],
Expand All @@ -326,6 +327,7 @@ describe('ExportMap', function () {

let imports
before('load imports', function () {
this.timeout(20000) // takes a long time :shrug:
imports = ExportMap.get('./typescript.ts', context)
})

Expand Down

0 comments on commit 2e05c3f

Please sign in to comment.