Skip to content

Commit

Permalink
added path.resolve to Node resolver, hoping to obviate SublimeLinter …
Browse files Browse the repository at this point in the history
…workaround.
  • Loading branch information
benmosher committed Dec 7, 2015
1 parent ee110ef commit 2f82fd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 38 deletions.
35 changes: 0 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names. All the goodness that the ES2015+ static module syntax intends to provide, marked up in your editor.

**IF YOU ARE USING THIS WITH SUBLIME**: see the [bottom section](#sublimelinter-eslint) for important info.

## Rules

* Ensure imports point to a file/module that can be resolved. ([`no-unresolved`](#no-unresolved))
Expand Down Expand Up @@ -401,36 +399,3 @@ settings:

import/parser: esprima-fb # default is 'babylon'. change if needed.
```
## SublimeLinter-eslint
Recently, SublimeLinter-eslint introduced a change to support `.eslintignore` files
which altered the way file paths are passed to ESLint when linting during editing.

See roadhump/SublimeLinter-eslint#58 for more details, but essentially, you may find
you need to add the following to a `.sublimelinterrc` file:

```json
{
"linters": {
"eslint": {
"args": ["--stdin-filename", "@"]
}
}
}
```

I also found that I needed to set `rc_search_limit` to `null`, which removes the file
hierarchy search limit when looking up the directory tree for `.sublimelinterrc`:

In Package Settings / SublimeLinter / User Settings:
```json
{
"user": {
"rc_search_limit": null
}
}
```

I believe this defaults to `3`, so you may not need to alter it depending on your
project folder max depth.
7 changes: 4 additions & 3 deletions resolvers/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ var resolve = require('resolve')
exports.resolveImport = function resolveImport(source, file, config) {
if (resolve.isCore(source)) return null

return resolve.sync(source, opts(path.dirname(file), config))
return resolve.sync(source, opts(file, config))
}

function opts(basedir, config) {
function opts(file, config) {
return assign({},
config,
{
basedir: basedir,
// path.resolve will handle paths relative to CWD
basedir: path.dirname(path.resolve(file)),
packageFilter: packageFilter,

})
Expand Down

0 comments on commit 2f82fd1

Please sign in to comment.