Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pr-794
Browse files Browse the repository at this point in the history
* origin/master: (66 commits)
  [Fix] unescape unnecessarily escaped regex slashes
  [Dev Deps] dev dep ranges should match peer dep ranges
  docs(readme): add space (import-js#888)
  bump to v2.7.0
  changelog note for import-js#843
  upgraded no-absolute-path to use `moduleVisitor` pattern to support all module systems
  PR note fixes
  bump to v2.6.1 to bump dep on node resolver to latest 😳
  Update no-extraneous-dependencies.md (import-js#878)
  Fix flow interface imports giving false-negative with `named` rule
  bump to 2.6.0, node/0.3.1, webpack/0.8.3, memo-parser/0.2.0
  chore(eslint): upgrade to eslint@4
  memo-parser: require eslint >= 3.5.0 (need file path always)
  build on node v4, again (import-js#855)
  bump to v2.5.0
  bump `debug` version everywhere
  resolvers/webpack: v0.8.2
  eslint-module-utils: v2.1.1 (bumping to re-publish to npm)
  [Tests] comment out failing (and probably invalid) test
  Only apps should have lockfiles.
  ...
  • Loading branch information
Spain committed Aug 2, 2017
2 parents 2c47c6f + dd28130 commit 911b373
Show file tree
Hide file tree
Showing 52 changed files with 839 additions and 140 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ node_modules
# generated output
lib/
**/.nyc_output/

# Only apps should have lockfiles
yarn.lock
package-lock.json
npm-shrinkwrap.json
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
11 changes: 10 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ language: node_js
node_js:
- 4
- 6
- 8

os:
- linux
- osx

env:
- ESLINT_VERSION=2
- ESLINT_VERSION=3
- ESLINT_VERSION=4

install:
- npm -g install npm@3
- if [ ${TRAVIS_NODE_VERSION} == "4" ]; then
npm install -g npm@3;
fi
- npm install
- npm install eslint@$ESLINT_VERSION --ignore-scripts || true
# install all resolver deps
- "for resolver in ./resolvers/*; do cd $resolver && npm install && cd ../..; done"

Expand Down
62 changes: 60 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,54 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]

### Fixed
- [`order`]: Fix interpreting some external modules being interpreted as internal modules ([#793], [#794] thanks [@ephys])

## [2.7.0] - 2017-07-06
### Changed
- [`no-absolute-path`] picks up speed boost, optional AMD support ([#843], thansk [@jseminck])

## [2.6.1] - 2017-06-29
### Fixed
- update bundled node resolver dependency to latest version

## [2.6.0] - 2017-06-23
### Changed
- update tests / peerDeps for ESLint 4.0 compatibility ([#871], thanks [@mastilver])
- [`memo-parser`] updated to require `filePath` on parser options as it melts
down if it's not there, now that this plugin always provides it. (see [#863])

## [2.5.0] - 2017-06-22

Re-releasing v[2.4.0] after discovering that the memory leak is isolated to the [`memo-parser`],
which is more or less experimental anyway.

### Added
- Autofixer for newline-after-import. ([#686] + [#696], thanks [@eelyafi])

## [2.4.0] - 2017-06-02 [YANKED]

Yanked due to critical issue in eslint-module-utils with cache key resulting from [#839].

### Added
- Add `filePath` into `parserOptions` passed to `parser` ([#839], thanks [@sompylasar])
- Add `allow` option to [`no-unassigned-import`] to allow for files that match the globs ([#671], [#737], thanks [@kevin940726]).

## [2.3.0] - 2017-05-18
### Added
- [`no-anonymous-default-export`] rule: report anonymous default exports ([#712], thanks [@duncanbeevers]).
- Add new value to [`order`]'s `newlines-between` option to allow newlines inside import groups ([#627], [#628], thanks [@giodamelio])
- Add `count` option to the [`newline-after-import`] rule to allow configuration of number of newlines expected ([#742], thanks [@ntdb])

### Changed
- [`no-extraneous-dependencies`]: use `read-pkg-up` to simplify finding + loading `package.json` ([#680], thanks [@wtgtybhertgeghgtwtg])
- Add support to specify the package.json [`no-extraneous-dependencies`] ([#685], thanks [@ramasilveyra])

### Fixed
- [`order`]: Fix interpreting some external modules being interpreted as internal modules ([#793], [#794] thanks [@ephys])
- attempt to fix crash in [`no-mutable-exports`]. ([#660])
- "default is a reserved keyword" in no-maned-default tests by locking down babylon to 6.15.0 (#756, thanks @gmathieu)
- support scoped modules containing non word characters


## [2.2.0] - 2016-11-07
Expand Down Expand Up @@ -384,10 +420,16 @@ for info on changes for earlier releases.
[`no-unassigned-import`]: ./docs/rules/no-unassigned-import.md
[`unambiguous`]: ./docs/rules/unambiguous.md
[`no-anonymous-default-export`]: ./docs/rules/no-anonymous-default-export.md
[`memo-parser`]: ./memo-parser/README.md

[#794]: https://github.com/benmosher/eslint-plugin-import/pull/794
[#843]: https://github.com/benmosher/eslint-plugin-import/pull/843
[#871]: https://github.com/benmosher/eslint-plugin-import/pull/871
[#742]: https://github.com/benmosher/eslint-plugin-import/pull/742
[#737]: https://github.com/benmosher/eslint-plugin-import/pull/737
[#712]: https://github.com/benmosher/eslint-plugin-import/pull/712
[#696]: https://github.com/benmosher/eslint-plugin-import/pull/696
[#685]: https://github.com/benmosher/eslint-plugin-import/pull/685
[#680]: https://github.com/benmosher/eslint-plugin-import/pull/680
[#654]: https://github.com/benmosher/eslint-plugin-import/pull/654
[#639]: https://github.com/benmosher/eslint-plugin-import/pull/639
Expand Down Expand Up @@ -443,6 +485,10 @@ for info on changes for earlier releases.
[#314]: https://github.com/benmosher/eslint-plugin-import/pull/314

[#793]: https://github.com/benmosher/eslint-plugin-import/issues/793
[#863]: https://github.com/benmosher/eslint-plugin-import/issues/863
[#839]: https://github.com/benmosher/eslint-plugin-import/issues/839
[#686]: https://github.com/benmosher/eslint-plugin-import/issues/686
[#671]: https://github.com/benmosher/eslint-plugin-import/issues/671
[#660]: https://github.com/benmosher/eslint-plugin-import/issues/660
[#653]: https://github.com/benmosher/eslint-plugin-import/issues/653
[#627]: https://github.com/benmosher/eslint-plugin-import/issues/627
Expand Down Expand Up @@ -500,7 +546,13 @@ 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.2.0...HEAD
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.7.0...HEAD
[2.7.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.6.1...v2.7.0
[2.6.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.6.0...v2.6.1
[2.6.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.5.0...v2.6.0
[2.5.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.4.0...v2.5.0
[2.4.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.3.0...v2.4.0
[2.3.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.2.0...v2.3.0
[2.2.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.0.0...v2.0.1
Expand Down Expand Up @@ -578,4 +630,10 @@ for info on changes for earlier releases.
[@duncanbeevers]: https://github.com/duncanbeevers
[@giodamelio]: https://github.com/giodamelio
[@ntdb]: https://github.com/ntdb
[@ramasilveyra]: https://github.com/ramasilveyra
[@sompylasar]: https://github.com/sompylasar
[@kevin940726]: https://github.com/kevin940726
[@eelyafi]: https://github.com/eelyafi
[@mastilver]: https://github.com/mastilver
[@jseminck]: https://github.com/jseminck
[@ephys]: https://github.com/ephys
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ In the interest of supporting both of these, v0.11 introduces resolvers.
Currently [Node] and [Webpack] resolution have been implemented, but the
resolvers are just npm packages, so [third party packages are supported](https://github.com/benmosher/eslint-plugin-import/wiki/Resolvers) (and encouraged!).

You can reference resolvers in several ways(in order of precedence):
You can reference resolvers in several ways (in order of precedence):

- as a conventional `eslint-import-resolver` name, like `eslint-import-resolver-foo`:

Expand Down
3 changes: 1 addition & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
```

Generally, don't use `npm version` for this because it creates a tag, which I normally
wait until signoff from all contributors (`new Set(["@jfmengels"])`) and actually
`npm publish`-ing to snap the tag.
wait until signoff from contributors and actually `npm publish`-ing to snap the tag.

3. create pull request from `release-[x.y.z]` into `release` branch

Expand Down
11 changes: 6 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Test against this version of Node.js
environment:
matrix:
- nodejs_version: "4"
- nodejs_version: "8"
- nodejs_version: "6"
- nodejs_version: "4"

# platform:
# - x86
Expand All @@ -13,11 +14,11 @@ install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version

# update npm (only needed for Node 0.10)
- npm -g install npm@3
# - set PATH=%APPDATA%\npm;%PATH%

# install modules
- ps: >-
if ($env:nodejs_version -eq "4") {
npm install -g npm@3;
}
- npm install

# todo: learn how to do this for all .\resolvers\* on Windows
Expand Down
3 changes: 2 additions & 1 deletion docs/rules/newline-after-import.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# newline-after-import

Enforces having one or more empty lines after the last top-level import statement or require call.
+(fixable) The `--fix` option on the [command line] automatically fixes problems reported by this rule.

## Rule Details

Expand Down Expand Up @@ -76,7 +77,7 @@ const FOO = 'BAR'
{
...
"rules": {
"import/newline-after-import": [{ "count": 2 }]
"import/newline-after-import": ["error", { "count": 2 }]
}
}
```
Expand Down
21 changes: 21 additions & 0 deletions docs/rules/no-absolute-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,24 @@ var _ = require('lodash');
var foo = require('foo');
var foo = require('./foo');
```

### Options

By default, only ES6 imports and CommonJS `require` calls will have this rule enforced.

You may provide an options object providing true/false for any of

- `esmodule`: defaults to `true`
- `commonjs`: defaults to `true`
- `amd`: defaults to `false`

If `{ amd: true }` is provided, dependency paths for AMD-style `define` and `require`
calls will be resolved:

```js
/*eslint import/no-absolute-path: [2, { commonjs: false, amd: true }]*/
define(['/foo'], function (foo) { /*...*/ }) // reported
require(['/foo'], function (foo) { /*...*/ }) // reported

const foo = require('/foo') // ignored because of explicit `commonjs: false`
```
12 changes: 9 additions & 3 deletions docs/rules/no-extraneous-dependencies.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Forbid the use of extraneous packages

Forbid the import of external modules that are not declared in the `package.json`'s `dependencies`, `devDependencies`, `optionalDependencies` or `peerDependencies`.
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything.
The closest parent `package.json` will be used. If no `package.json` is found, the rule will not lint anything. This behaviour can be changed with the rule option `packageDir`.

### Options

Expand All @@ -25,7 +25,13 @@ You can also use an array of globs instead of literal booleans:
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.js", "**/*.spec.js"]}]
```

When using an array of globs, the setting will be activated if the name of the file being linted matches a single glob in the array.
When using an array of globs, the setting will be set to `true` (no errors reported) if the name of the file being linted matches a single glob in the array, and `false` otherwise.

Also there is one more option called `packageDir`, this option is to specify the path to the folder containing package.json and is relative to the current working directory.

```js
"import/no-extraneous-dependencies": ["error", {"packageDir": './some-dir/'}]
```

## Rule Details

Expand Down Expand Up @@ -83,7 +89,7 @@ var foo = require('./foo');

import test from 'ava';
import find from 'lodash.find';
import find from 'lodash.isarray';
import isArray from 'lodash.isarray';

/* eslint import/no-extraneous-dependencies: ["error", {"peerDependencies": true}] */
import react from 'react';
Expand Down
22 changes: 22 additions & 0 deletions docs/rules/no-unassigned-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@ With both CommonJS' `require` and the ES6 modules' `import` syntax, it is possib

This rule aims to remove modules with side-effects by reporting when a module is imported but not assigned.

### Options

This rule supports the following option:

`allow`: An Array of globs. The files that match any of these patterns would be ignored/allowed by the linter. This can be useful for some build environments (e.g. css-loader in webpack).

Note that the globs start from the where the linter is executed (usually project root), but not from each file that includes the source. Learn more in both the pass and fail examples below.


## Fail

```js
import 'should'
require('should')

// In <PROJECT_ROOT>/src/app.js
import '../styles/app.css'
// {"allow": ["styles/*.css"]}
```


Expand All @@ -34,4 +47,13 @@ bar(require('foo'))
require('foo').bar
require('foo').bar()
require('foo')()

// With allow option set
import './style.css' // {"allow": ["**/*.css"]}
import 'babel-register' // {"allow": ["babel-register"]}

// In <PROJECT_ROOT>/src/app.js
import './styles/app.css'
import '../scripts/register.js'
// {"allow": ["src/styles/**", "**/scripts/*.js"]}
```
5 changes: 4 additions & 1 deletion memo-parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ const parserOptions = {
}

exports.parse = function parse(content, options) {
// them defaults yo
options = Object.assign({}, options, parserOptions)

if (!options.filePath) {
throw new Error("no file path provided!")
}

const keyHash = crypto.createHash('sha256')
keyHash.update(content)
hashObject(options, keyHash)
Expand Down
11 changes: 8 additions & 3 deletions memo-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "memo-parser",
"version": "0.1.0",
"engines": { "node": ">=4" },
"version": "0.2.0",
"engines": {
"node": ">=4"
},
"description": "Memoizing wrapper for any ESLint-compatible parser module.",
"main": "index.js",
"scripts": {
Expand All @@ -21,5 +23,8 @@
"bugs": {
"url": "https://github.com/benmosher/eslint-plugin-import/issues"
},
"homepage": "https://github.com/benmosher/eslint-plugin-import#readme"
"homepage": "https://github.com/benmosher/eslint-plugin-import#readme",
"peerDependencies": {
"eslint": ">=3.5.0"
}
}
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-import",
"version": "2.2.0",
"version": "2.7.0",
"description": "Import with sanity.",
"engines": {
"node": ">=4"
Expand Down Expand Up @@ -51,12 +51,12 @@
"babel-eslint": "next",
"babel-plugin-istanbul": "^2.0.1",
"babel-preset-es2015-argon": "latest",
"babel-register": "6.16.3",
"babel-register": "6.24.1",
"babylon": "6.15.0",
"chai": "^3.4.0",
"coveralls": "^2.11.4",
"cross-env": "^3.1.0",
"eslint": "3.x",
"cross-env": "^4.0.0",
"eslint": "2.x - 4.x",
"eslint-import-resolver-node": "file:./resolvers/node",
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
"eslint-module-utils": "file:./utils",
Expand All @@ -70,19 +70,20 @@
"nyc": "^8.3.0",
"redux": "^3.0.4",
"rimraf": "2.5.2",
"sinon": "^2.3.2",
"typescript": "^2.0.3",
"typescript-eslint-parser": "^1.0.0"
"typescript-eslint-parser": "^2.1.0"
},
"peerDependencies": {
"eslint": "2.x - 3.x"
"eslint": "2.x - 4.x"
},
"dependencies": {
"builtin-modules": "^1.1.1",
"contains-path": "^0.1.0",
"debug": "^2.2.0",
"debug": "^2.6.8",
"doctrine": "1.5.0",
"eslint-import-resolver-node": "^0.2.0",
"eslint-module-utils": "^2.0.0",
"eslint-import-resolver-node": "^0.3.1",
"eslint-module-utils": "^2.1.1",
"has": "^1.0.1",
"lodash.cond": "^4.3.0",
"minimatch": "^3.0.3",
Expand Down
Loading

0 comments on commit 911b373

Please sign in to comment.