Skip to content
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

build: run Travis against Linux and OS X #288

Closed
wants to merge 8 commits into from
Closed
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
4 changes: 4 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ rules:
comma-dangle: [2, always-multiline]
eqeqeq: [2, "allow-null"]
no-shadow: 1
quotes:
- 2
- single
- allowTemplateLiterals: true
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ 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).

## resolvers/webpack/0.2.2 - 2016-04-27
### Added
- `interpret` configs (such as `.babel.js`).
Thanks to [@gausie] for the initial PR ([#164], ages ago! 😅) and [@jquense] for tests ([#278]).

## [1.6.0] - 2016-04-25
### Added
- add [`no-named-as-default-member`] to `warnings` canned config
Expand Down Expand Up @@ -163,6 +168,7 @@ for info on changes for earlier releases.
[`order`]: ./docs/rules/order.md
[`named`]: ./docs/rules/named.md

[#278]: https://github.com/benmosher/eslint-plugin-import/pull/278
[#256]: https://github.com/benmosher/eslint-plugin-import/pull/256
[#254]: https://github.com/benmosher/eslint-plugin-import/pull/254
[#247]: https://github.com/benmosher/eslint-plugin-import/pull/247
Expand All @@ -172,6 +178,7 @@ for info on changes for earlier releases.
[#228]: https://github.com/benmosher/eslint-plugin-import/pull/228
[#211]: https://github.com/benmosher/eslint-plugin-import/pull/211
[#157]: https://github.com/benmosher/eslint-plugin-import/pull/157
[#164]: https://github.com/benmosher/eslint-plugin-import/pull/164

[#216]: https://github.com/benmosher/eslint-plugin-import/issues/216
[#214]: https://github.com/benmosher/eslint-plugin-import/issues/214
Expand Down Expand Up @@ -204,9 +211,11 @@ for info on changes for earlier releases.
[0.11.0]: https://github.com/benmosher/eslint-plugin-import/compare/v0.10.1...v0.11.0

[@mathieudutour]: https://github.com/mathieudutour
[@gausie]: https://github.com/gausie
[@singles]: https://github.com/singles
[@jfmengels]: https://github.com/jfmengels
[@lo1tuma]: https://github.com/lo1tuma
[@dmnd]: https://github.com/dmnd
[@lemonmade]: https://github.com/lemonmade
[@jimbolla]: https://github.com/jimbolla
[@jquense]: https://github.com/jquense
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"es6-set": "^0.1.4",
"es6-symbol": "*",
"eslint-import-resolver-node": "^0.2.0",
"interpret": "^1.0.0",
"lodash.cond": "^4.3.0",
"lodash.endswith": "^4.0.1",
"lodash.find": "^4.3.0",
Expand Down
37 changes: 37 additions & 0 deletions resolvers/webpack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var findRoot = require('find-root')
, resolve = require('resolve')
, get = require('lodash.get')
, find = require('array-find')
, interpret = require('interpret')
// not available on 0.10.x
, isAbsolute = path.isAbsolute || require('is-absolute')

Expand Down Expand Up @@ -32,6 +33,7 @@ exports.resolve = function (source, file, settings) {

var configPath = get(settings, 'config', 'webpack.config.js')
, webpackConfig

try {
// see if we've got an absolute path
if (!isAbsolute(configPath)) {
Expand All @@ -42,7 +44,19 @@ exports.resolve = function (source, file, settings) {
configPath = path.join(packageDir, configPath)
}

var ext = Object.keys(interpret.extensions).reduce(function (chosen, extension) {
var extlen = extension.length
return ((configPath.substr(-extlen) === extension) && (extlen > chosen.length))
? extension : chosen
}, '')

registerCompiler(interpret.extensions[ext])

webpackConfig = require(configPath)

if (webpackConfig && webpackConfig.default) {
webpackConfig = webpackConfig.default
}
} catch (err) {
webpackConfig = {}
}
Expand All @@ -57,10 +71,12 @@ exports.resolve = function (source, file, settings) {

// root as first alternate path
var rootPath = get(webpackConfig, ['resolve', 'root'])

if (rootPath) {
if (typeof rootPath === 'string') paths.push(rootPath)
else paths.push.apply(paths, rootPath)
}

// set fallback paths
var fallbackPath = get(webpackConfig, ['resolve', 'fallback'])
if (fallbackPath) {
Expand All @@ -71,6 +87,7 @@ exports.resolve = function (source, file, settings) {

// otherwise, resolve "normally"
try {

return { found: true, path: resolve.sync(source, {
basedir: path.dirname(file),

Expand Down Expand Up @@ -145,3 +162,23 @@ function packageFilter(config, pkg) {

return pkg
}


function registerCompiler(moduleDescriptor) {
if(moduleDescriptor) {
if(typeof moduleDescriptor === 'string') {
require(moduleDescriptor)
} else if(!Array.isArray(moduleDescriptor)) {
moduleDescriptor.register(require(moduleDescriptor.module))
} else {
for(var i = 0; i < moduleDescriptor.length; i++) {
try {
registerCompiler(moduleDescriptor[i])
break
} catch(e) {
// do nothing
}
}
}
}
}
2 changes: 1 addition & 1 deletion resolvers/webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-import-resolver-webpack",
"version": "0.2.1",
"version": "0.2.2",
"description": "Resolve paths to dependencies, given a webpack.config.js. Plugin for eslint-plugin-import.",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions resolvers/webpack/test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@ describe("config", function () {
expect(resolve('foo', file, absoluteSettings)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'some', 'absolutely', 'goofy', 'path', 'foo.js'))
})

it("finds compile-to-js configs", function () {
var settings = {
config: path.join(__dirname, './files/webpack.config.babel.js'),
}

expect(resolve('main-module', file, settings))
.to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'src', 'main-module.js'))
})
})
17 changes: 17 additions & 0 deletions resolvers/webpack/test/files/webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import path from 'path'

export default {
resolve: {
alias: {
'foo': path.join(__dirname, 'some', 'goofy', 'path', 'foo.js'),
},
modulesDirectories: ['node_modules', 'bower_components'],
root: path.join(__dirname, 'src'),
fallback: path.join(__dirname, 'fallback'),
},

externals: [
{ 'jquery': 'jQuery' },
'bootstrap',
],
}
2 changes: 1 addition & 1 deletion src/core/getExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ function captureDoc(...nodes) {
// capture XSDoc
n.leadingComments.forEach(comment => {
// skip non-block comments
if (comment.value.slice(0, 4) !== "*\n *") return
if (comment.value.slice(0, 4) !== '*\n *') return
try {
metadata.doc = doctrine.parse(comment.value, { unwrap: true })
} catch (err) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export function hashArray(hash, array) {
}

export function hashObject(hash, object) {
hash.update("{")
hash.update('{')
Object.keys(object).sort().forEach(key => {
hash.update(stringify(key))
hash.update(':')
hashify(hash, object[key])
hash.update(",")
hash.update(',')
})
hash.update("}")
hash.update('}')

return hash
}
4 changes: 2 additions & 2 deletions src/core/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import assign from 'object-assign'

export default function (content, context) {

if (context == null) throw new Error("need context to parse properly")
if (context == null) throw new Error('need context to parse properly')

let { parserOptions, parserPath } = context

if (!parserPath) throw new Error("parserPath is required!")
if (!parserPath) throw new Error('parserPath is required!')

// hack: espree blows up with frozen options
parserOptions = assign({}, parserOptions)
Expand Down
2 changes: 1 addition & 1 deletion src/core/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,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 && CASE_INSENSITIVE && fullPath !== null && !fileExistsWithCaseSync(fullPath, cacheSettings)) {
// reject resolved path
fullPath = undefined
}
Expand Down