Skip to content

Support Node v6 #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ node_js:
- 0.10
- 0.12
- 4
- stable
- 5
- 6

os:
- linux
- osx

install:
- npm -g install npm@3
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ All notable changes to this project 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
### Fixed
- [`no-named-as-default-member`]: don't crash on rest props. ([#281], thanks [@SimenB])
- support for Node 6: don't pass `null` to `path` functions.
Thanks to [@strawbrary] for bringing this up ([#272]) and adding OSX support to the Travis
config ([#288]).

## resolvers/webpack: Unreleased
### Changed
- automatically find webpack config with `interpret`-able extensions ([#287], thanks [@taion])
Expand Down Expand Up @@ -178,6 +185,7 @@ for info on changes for earlier releases.
[`named`]: ./docs/rules/named.md

[#289]: https://github.com/benmosher/eslint-plugin-import/pull/289
[#288]: https://github.com/benmosher/eslint-plugin-import/pull/288
[#287]: https://github.com/benmosher/eslint-plugin-import/pull/287
[#278]: https://github.com/benmosher/eslint-plugin-import/pull/278
[#261]: https://github.com/benmosher/eslint-plugin-import/pull/261
Expand All @@ -194,6 +202,8 @@ for info on changes for earlier releases.
[#164]: https://github.com/benmosher/eslint-plugin-import/pull/164

[#286]: https://github.com/benmosher/eslint-plugin-import/issues/286
[#281]: https://github.com/benmosher/eslint-plugin-import/issues/281
[#272]: https://github.com/benmosher/eslint-plugin-import/issues/272
[#216]: https://github.com/benmosher/eslint-plugin-import/issues/216
[#214]: https://github.com/benmosher/eslint-plugin-import/issues/214
[#210]: https://github.com/benmosher/eslint-plugin-import/issues/210
Expand Down Expand Up @@ -235,4 +245,5 @@ for info on changes for earlier releases.
[@jquense]: https://github.com/jquense
[@jonboiser]: https://github.com/jonboiser
[@taion]: https://github.com/taion
[@strawbrary]: https://github.com/strawbrary
[@SimenB]: https://github.com/SimenB
11 changes: 3 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# Test against this version of Node.js
environment:
nodejs_version: "4"
# killing build matrix in the interest of turnaround time
# matrix:
# - nodejs_version: "0.10"
# - nodejs_version: "0.12"
# - nodejs_version: "5"

# - nodejs_version: "2"
matrix:
- nodejs_version: "4"
- nodejs_version: "6"

# platform:
# - x86
Expand Down
10 changes: 8 additions & 2 deletions src/core/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import assign from 'object-assign'
import fs from 'fs'
import { dirname, basename, join } from 'path'

export const CASE_INSENSITIVE = fs.existsSync(join(__dirname, 'reSOLVE.js'))
export const CASE_SENSITIVE_FS = !fs.existsSync(join(__dirname, 'reSOLVE.js'))

const fileExistsCache = new Map()

Expand All @@ -26,6 +26,12 @@ function checkCache(cacheKey, { lifetime }) {

// http://stackoverflow.com/a/27382838
function fileExistsWithCaseSync(filepath, cacheSettings) {
// don't care if the FS is case-sensitive
if (CASE_SENSITIVE_FS) return true

// null means it resolved to a builtin
if (filepath === null) return true

const dir = dirname(filepath)

let result = checkCache(filepath, cacheSettings)
Expand Down Expand Up @@ -105,7 +111,7 @@ export function relative(modulePath, sourceFile, settings) {
let { path: fullPath, found } = withResolver(resolver, config)

// resolvers imply file existence, this double-check just ensures the case matches
if (found && CASE_INSENSITIVE && !fileExistsWithCaseSync(fullPath, cacheSettings)) {
if (found && !fileExistsWithCaseSync(fullPath, cacheSettings)) {
// reject resolved path
fullPath = undefined
}
Expand Down
9 changes: 5 additions & 4 deletions src/rules/no-named-as-default-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ module.exports = function(context) {
}

function handleDestructuringAssignment(node) {
if (!node.init) return

const isDestructure = (
node.id.type === 'ObjectPattern' && node.init.type === 'Identifier'
node.id.type === 'ObjectPattern' &&
node.init != null &&
node.init.type === 'Identifier'
)
if (!isDestructure) return

const objectName = node.init.name
for (const {key} of node.id.properties) {
for (const { key } of node.id.properties) {
if (key == null) continue // true for rest properties
storePropertyLookup(objectName, key.name, key)
}
}
Expand Down
5 changes: 2 additions & 3 deletions tests/src/rules/no-named-as-default-member.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {test} from '../utils'
import { test, SYNTAX_CASES } from '../utils'
import {RuleTester} from 'eslint'
import rule from 'rules/no-named-as-default-member'

Expand All @@ -11,8 +11,7 @@ ruleTester.run('no-named-as-default-member', rule, {
test({code: 'import {foo} from "./bar"; const baz = foo.baz;'}),
test({code: 'import * as named from "./named-exports"; const a = named.a'}),

// issue #249
test({code: 'for (const {foo, bar} of baz) {}'}),
...SYNTAX_CASES,
],

invalid: [
Expand Down
30 changes: 30 additions & 0 deletions tests/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,33 @@ export function testContext(settings) {
export function getFilename(file) {
return path.join(__dirname, '..', 'files', file || 'foo.js')
}

/**
* to be added as valid cases just to ensure no nullable fields are going
* to crash at runtinme
* @type {Array}
*/
export const SYNTAX_CASES = [

test({ code: 'for (let { foo, bar } of baz) {}' }),
test({ code: 'for (let [ foo, bar ] of baz) {}' }),

test({ code: 'const { x, y } = bar' }),
test({ code: 'const { x, y, ...z } = bar', parser: 'babel-eslint' }),

// all the exports
test({ code: 'export { x }' }),
test({ code: 'export { x as y }' }),

// not sure about these since they reference a file
// test({ code: 'export { x } from "./y.js"'}),
// test({ code: 'export * as y from "./y.js"', parser: 'babel-eslint'}),

test({ code: 'export const x = null' }),
test({ code: 'export var x = null' }),
test({ code: 'export let x = null' }),

test({ code: 'export default x' }),
test({ code: 'export default class x {}' }),

]