import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.56k stars 1.57k forks source link

Failing to resolve paths. #53

Closed rhys-vdw closed 9 years ago

rhys-vdw commented 9 years ago

Hi, presumably I'm doing something wrong here, but I couldn't find any info. I've just installed and added this plugin to my .eslintrc:

{
  "parser": "babel-eslint",
  "extends": "eslint:recommended",
  "plugins": [ "react", "import" ],
  "rules": {
    "comma-dangle": 0,
    "no-unused-vars": [2, {"vars": "all", "args": "none"}],
    "no-console": 1,
    "no-var": 2,
    "no-debugger": 1,
    "indent": [2, 2, {"SwitchCase": 1}],
    "max-len": [1, 80, 2],
    "prefer-const": 2
  },
  "settings": {
    "import/resolve": {
      "extenstions": [ ".es6", ".js", ".jsx" ]
    },
    "import/parser": "babel-eslint"
  },
  "env": {
    "browser": true
  }
}

But when I parse I get this:

/Users/rhys/Projects/2suggestions/paydirt/app/assets/javascripts/es6/components/projects/show_details.es6
  4:41  error    Unable to resolve path to module '../input/dropdown'        import/no-unresolved
  4:41  warning  'null' imported multiple times                              import/no-duplicates
  5:20  error    Unable to resolve path to module './status'                 import/no-unresolved
  5:20  warning  'null' imported multiple times                              import/no-duplicates
  6:18  error    Unable to resolve path to module '../icon'                  import/no-unresolved
  6:18  warning  'null' imported multiple times                              import/no-duplicates
  7:48  error    Unable to resolve path to module '../../entities/projects'  import/no-unresolved
  7:48  warning  'null' imported multiple times                              import/no-duplicates
  8:29  error    Unable to resolve path to module '../anchors'               import/no-unresolved
  8:29  warning  'null' imported multiple times                              import/no-duplicates
// show_details.es6

import Dropdown, { Item, Divider } from '../input/dropdown';
import Status from './status';
import Icon from '../icon';
import { hasHourly, invoiceUrl, moveUrl } from '../../entities/projects';
import { ModalAnchor } from '../anchors';

// ...

I'd really appreciate some help, this looks to be an excellent tool!

rhys-vdw commented 9 years ago
$ node -v
v0.12.4

$ npm ls -g --depth=0
├── babel@5.8.23
├── babel-eslint@4.1.3
├── eslint@1.6.0
├── eslint-plugin-import@0.8.0
├── eslint-plugin-react@3.5.1
├── npm@3.3.5
└── webpack@1.12.2
benmosher commented 9 years ago

Looks like "extenstions" setting is misspelled? Should be "extensions".

--Ben

On Oct 13, 2015, at 21:56, Rhys van der Waerden notifications@github.com wrote:

Hi, presumably I'm doing something wrong here, but I couldn't find any info. I've just installed and added this plugin to my .eslintrc:

{ "parser": "babel-eslint", "extends": "eslint:recommended", "plugins": [ "react", "import" ], "rules": { "comma-dangle": 0, "no-unused-vars": [2, {"vars": "all", "args": "none"}], "no-console": 1, "no-var": 2, "no-debugger": 1, "indent": [2, 2, {"SwitchCase": 1}], "max-len": [1, 80, 2], "prefer-const": 2 }, "settings": { "import/resolve": { "extenstions": [ ".es6", ".js", ".jsx" ] }, "import/parser": "babel-eslint" }, "env": { "browser": true } } But when I parse I get this:

/Users/rhys/Projects/2suggestions/paydirt/app/assets/javascripts/es6/components/projects/show_details.es6 4:41 error Unable to resolve path to module '../input/dropdown' import/no-unresolved 4:41 warning 'null' imported multiple times import/no-duplicates 5:20 error Unable to resolve path to module './status' import/no-unresolved 5:20 warning 'null' imported multiple times import/no-duplicates 6:18 error Unable to resolve path to module '../icon' import/no-unresolved 6:18 warning 'null' imported multiple times import/no-duplicates 7:48 error Unable to resolve path to module '../../entities/projects' import/no-unresolved 7:48 warning 'null' imported multiple times import/no-duplicates 8:29 error Unable to resolve path to module '../anchors' import/no-unresolved 8:29 warning 'null' imported multiple times import/no-duplicates // show_details.es6

import { basecampUrl, hasBasecamp, hasHourly, hasRedbooth, hasTrello, hasUnbilled, invoiceUrl, redboothUrl, trelloUrl, unbilledValueString } from '../../entities/projects'; import { JsAnchor } from '../anchors'; import Icon from '../icon';

// ... I'd really appreciate some help, this looks to be an excellent tool!

— Reply to this email directly or view it on GitHub.

rhys-vdw commented 9 years ago

@benmosher :blush: thanks.

rhys-vdw commented 9 years ago

Working beautifully! :+1:

benmosher commented 9 years ago

🙏

JulianKlug commented 8 years ago

Hi, I have the same problem, but i can't resolve it by a right spelling of extensions.

{
  "name": "databridge-logger",
  "version": "1.0.0",
  "description": "aggregate logs from all databridge clients",
  "main": "./src/index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node ./server.js",
    "lint": "node ./node_modules/eslint/bin/eslint.js src"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/DataBridge/logger.git"
  },
  "keywords": [
    "databridge",
    "log"
  ],
  "author": "Guillaume Leclerc <guillaume.leclerc.work@gmail.com>",
  "license": "UNLICENCED",
  "bugs": {
    "url": "https://github.com/DataBridge/logger/issues"
  },
  "homepage": "https://github.com/DataBridge/logger#readme",
  "dependencies": {
    "babel-core": "^6.13.2",
    "babel-plugin-transform-async-to-generator": "^6.8.0",
    "babel-plugin-transform-class-properties": "^6.11.5",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-plugin-transform-flow-strip-types": "^6.8.0",
    "babel-plugin-transform-object-rest-spread": "^6.8.0",
    "babel-polyfill": "^6.13.0",
    "babel-preset-es2015": "^6.13.2",
    "babel-preset-stage-0": "^6.5.0",
    "babel-register": "^6.11.6",
    "chance": "^1.0.4",
    "co-body": "^4.2.0",
    "koa": "^2.0.0",
    "lodash": "^4.15.0",
    "mz": "^2.4.0",
    "performance-now": "^0.2.0",
    "superagent": "^2.2.0"
  },
  "devDependencies": {
    "babel-eslint": "^6.1.2",
    "eslint": "^3.3.1",
    "eslint-config-airbnb": "^10.0.1",
    "eslint-plugin-jsx-a11y": "^2.1.0",
    "eslint-plugin-flowtype": "^2.11.0",
    "eslint-plugin-import": "^1.13.0",
    "eslint-plugin-jsx-a11y": "^2.1.0",
    "eslint-plugin-react": "^6.1.2"
  }
}

And i get the error "Unable to resolve path" for every module, but "path".

   6:20  error  Unable to resolve path to module 'chance'           import/no-unresolved
   7:17  error  Unable to resolve path to module 'koa'              import/no-unresolved
   8:17  error  Unable to resolve path to module 'performance-now'  import/no-unresolved
   9:23  error  Unable to resolve path to module 'lodash'           import/no-unresolved
  10:19  error  Unable to resolve path to module 'co-body'          import/no-unresolved
  11:26  error  Unable to resolve path to module 'jsonschema'       import/no-unresolved
  14:25  error  Unable to resolve path to module './backends/file'  import/no-unresolved
  15:20  error  Unable to resolve path to module './Logger'         import/no-unresolved
  16:23  error  Unable to resolve path to module './logSchema'      import/no-unresolved

I haven't been able to find a solution, does anyone have an idea ?

JulianKlug commented 8 years ago

Here are my installed dependecies :

+-- babel-core@6.14.0
| +-- babel-code-frame@6.11.0
| | `-- js-tokens@2.0.0
| +-- babel-generator@6.14.0
| | `-- detect-indent@3.0.1
| |   +-- get-stdin@4.0.1
| |   +-- minimist@1.2.0
| |   `-- repeating@1.1.3
| |     `-- is-finite@1.0.1
| +-- babel-helpers@6.8.0
| +-- babel-messages@6.8.0
| +-- babel-runtime@6.11.6
| +-- babel-template@6.14.0
| +-- babel-traverse@6.14.0
| | +-- globals@8.18.0
| | `-- invariant@2.2.1
| |   `-- loose-envify@1.2.0
| |     `-- js-tokens@1.0.3
| +-- babel-types@6.14.0
| | `-- to-fast-properties@1.0.2
| +-- babylon@6.9.1
| +-- convert-source-map@1.3.0
| +-- debug@2.2.0
| | `-- ms@0.7.1
| +-- json5@0.4.0
| +-- minimatch@3.0.3
| | `-- brace-expansion@1.1.6
| |   +-- balanced-match@0.4.2
| |   `-- concat-map@0.0.1
| +-- path-exists@1.0.0
| +-- path-is-absolute@1.0.0
| +-- private@0.1.6
| +-- shebang-regex@1.0.0
| +-- slash@1.0.0
| `-- source-map@0.5.6
+-- babel-eslint@6.1.2
| +-- lodash.assign@4.2.0
| `-- lodash.pickby@4.6.0
+-- babel-plugin-transform-async-to-generator@6.8.0
| +-- babel-helper-remap-async-to-generator@6.11.2
| `-- babel-plugin-syntax-async-functions@6.13.0
+-- babel-plugin-transform-class-properties@6.11.5
| +-- babel-helper-function-name@6.8.0
| | `-- babel-helper-get-function-arity@6.8.0
| `-- babel-plugin-syntax-class-properties@6.13.0
+-- babel-plugin-transform-decorators-legacy@1.3.4
| `-- babel-plugin-syntax-decorators@6.13.0
+-- babel-plugin-transform-flow-strip-types@6.14.0
| `-- babel-plugin-syntax-flow@6.13.0
+-- babel-plugin-transform-object-rest-spread@6.8.0
| `-- babel-plugin-syntax-object-rest-spread@6.13.0
+-- babel-polyfill@6.13.0
| +-- core-js@2.4.1
| `-- regenerator-runtime@0.9.5
+-- babel-preset-es2015@6.14.0
| +-- babel-plugin-check-es2015-constants@6.8.0
| +-- babel-plugin-transform-es2015-arrow-functions@6.8.0
| +-- babel-plugin-transform-es2015-block-scoped-functions@6.8.0
| +-- babel-plugin-transform-es2015-block-scoping@6.14.0
| +-- babel-plugin-transform-es2015-classes@6.14.0
| | +-- babel-helper-define-map@6.9.0
| | +-- babel-helper-optimise-call-expression@6.8.0
| | `-- babel-helper-replace-supers@6.14.0
| +-- babel-plugin-transform-es2015-computed-properties@6.8.0
| +-- babel-plugin-transform-es2015-destructuring@6.9.0
| +-- babel-plugin-transform-es2015-duplicate-keys@6.8.0
| +-- babel-plugin-transform-es2015-for-of@6.8.0
| +-- babel-plugin-transform-es2015-function-name@6.9.0
| +-- babel-plugin-transform-es2015-literals@6.8.0
| +-- babel-plugin-transform-es2015-modules-amd@6.8.0
| +-- babel-plugin-transform-es2015-modules-commonjs@6.14.0
| | `-- babel-plugin-transform-strict-mode@6.11.3
| +-- babel-plugin-transform-es2015-modules-systemjs@6.14.0
| | `-- babel-helper-hoist-variables@6.8.0
| +-- babel-plugin-transform-es2015-modules-umd@6.12.0
| +-- babel-plugin-transform-es2015-object-super@6.8.0
| +-- babel-plugin-transform-es2015-parameters@6.11.4
| | `-- babel-helper-call-delegate@6.8.0
| +-- babel-plugin-transform-es2015-shorthand-properties@6.8.0
| +-- babel-plugin-transform-es2015-spread@6.8.0
| +-- babel-plugin-transform-es2015-sticky-regex@6.8.0
| | `-- babel-helper-regex@6.9.0
| +-- babel-plugin-transform-es2015-template-literals@6.8.0
| +-- babel-plugin-transform-es2015-typeof-symbol@6.8.0
| +-- babel-plugin-transform-es2015-unicode-regex@6.11.0
| | `-- regexpu-core@2.0.0
| |   +-- regenerate@1.3.1
| |   +-- regjsgen@0.2.0
| |   `-- regjsparser@0.1.5
| |     `-- jsesc@0.5.0
| `-- babel-plugin-transform-regenerator@6.14.0
+-- babel-preset-stage-0@6.5.0
| +-- babel-plugin-transform-do-expressions@6.8.0
| | `-- babel-plugin-syntax-do-expressions@6.13.0
| +-- babel-plugin-transform-function-bind@6.8.0
| | `-- babel-plugin-syntax-function-bind@6.13.0
| `-- babel-preset-stage-1@6.13.0
|   +-- babel-plugin-transform-class-constructor-call@6.8.0
|   | `-- babel-plugin-syntax-class-constructor-call@6.13.0
|   +-- babel-plugin-transform-export-extensions@6.8.0
|   | `-- babel-plugin-syntax-export-extensions@6.13.0
|   `-- babel-preset-stage-2@6.13.0
|     +-- babel-plugin-transform-decorators@6.13.0
|     | `-- babel-helper-explode-class@6.8.0
|     |   `-- babel-helper-bindify-decorators@6.8.0
|     `-- babel-preset-stage-3@6.11.0
|       +-- babel-plugin-syntax-trailing-function-commas@6.13.0
|       `-- babel-plugin-transform-exponentiation-operator@6.8.0
|         +-- babel-helper-builder-binary-assignment-operator-visitor@6.8.0
|         | `-- babel-helper-explode-assignable-expression@6.8.0
|         `-- babel-plugin-syntax-exponentiation-operator@6.13.0
+-- babel-register@6.14.0
| +-- home-or-tmp@1.0.0
| | +-- os-tmpdir@1.0.1
| | `-- user-home@1.1.1
| +-- mkdirp@0.5.1
| | `-- minimist@0.0.8
| `-- source-map-support@0.2.10
|   `-- source-map@0.1.32
|     `-- amdefine@1.0.0
+-- chance@1.0.4
+-- co-body@4.2.0
| +-- inflation@2.0.0
| +-- qs@4.0.0
| +-- raw-body@2.1.7
| | +-- bytes@2.4.0
| | +-- iconv-lite@0.4.13
| | `-- unpipe@1.0.0
| `-- type-is@1.6.13
|   `-- media-typer@0.3.0
+-- eslint@3.3.1
| +-- chalk@1.1.3
| | +-- ansi-styles@2.2.1
| | +-- escape-string-regexp@1.0.5
| | +-- has-ansi@2.0.0
| | +-- strip-ansi@3.0.1
| | `-- supports-color@2.0.0
| +-- concat-stream@1.5.1
| | +-- inherits@2.0.1
| | +-- readable-stream@2.0.6
| | `-- typedarray@0.0.6
| +-- doctrine@1.3.0
| | `-- isarray@1.0.0
| +-- escope@3.6.0
| | +-- es6-weak-map@2.0.1
| | `-- esrecurse@4.1.0
| |   `-- estraverse@4.1.1
| +-- espree@3.1.7
| | +-- acorn@3.3.0
| | `-- acorn-jsx@3.0.1
| +-- estraverse@4.2.0
| +-- esutils@2.0.2
| +-- file-entry-cache@1.3.1
| | `-- flat-cache@1.2.1
| |   +-- circular-json@0.3.1
| |   +-- del@2.2.2
| |   | +-- globby@5.0.0
| |   | | +-- array-union@1.0.2
| |   | | | `-- array-uniq@1.0.3
| |   | | `-- arrify@1.0.1
| |   | +-- is-path-cwd@1.0.0
| |   | +-- is-path-in-cwd@1.0.0
| |   | | `-- is-path-inside@1.0.0
| |   | +-- pify@2.3.0
| |   | `-- rimraf@2.5.4
| |   +-- graceful-fs@4.1.6
| |   `-- write@0.2.1
| +-- glob@7.0.6
| | +-- fs.realpath@1.0.0
| | +-- inflight@1.0.5
| | | `-- wrappy@1.0.2
| | `-- once@1.3.3
| +-- globals@9.9.0
| +-- ignore@3.1.5
| +-- imurmurhash@0.1.4
| +-- inquirer@0.12.0
| | +-- ansi-escapes@1.4.0
| | +-- ansi-regex@2.0.0
| | +-- cli-cursor@1.0.2
| | | `-- restore-cursor@1.0.1
| | |   +-- exit-hook@1.1.1
| | |   `-- onetime@1.1.0
| | +-- cli-width@2.1.0
| | +-- figures@1.7.0
| | +-- readline2@1.0.1
| | | +-- code-point-at@1.0.0
| | | | `-- number-is-nan@1.0.0
| | | +-- is-fullwidth-code-point@1.0.0
| | | `-- mute-stream@0.0.5
| | +-- run-async@0.1.0
| | +-- rx-lite@3.1.2
| | +-- string-width@1.0.2
| | `-- through@2.3.8
| +-- is-my-json-valid@2.13.1
| | +-- generate-function@2.0.0
| | +-- generate-object-property@1.2.0
| | | `-- is-property@1.0.2
| | +-- jsonpointer@2.0.0
| | `-- xtend@4.0.1
| +-- is-resolvable@1.0.0
| | `-- tryit@1.0.2
| +-- js-yaml@3.6.1
| | +-- argparse@1.0.7
| | | `-- sprintf-js@1.0.3
| | `-- esprima@2.7.3
| +-- json-stable-stringify@1.0.1
| | `-- jsonify@0.0.0
| +-- levn@0.3.0
| | +-- prelude-ls@1.1.2
| | `-- type-check@0.3.2
| +-- natural-compare@1.4.0
| +-- optionator@0.8.1
| | +-- deep-is@0.1.3
| | +-- fast-levenshtein@1.1.4
| | `-- wordwrap@1.0.0
| +-- path-is-inside@1.0.1
| +-- pluralize@1.2.1
| +-- progress@1.1.8
| +-- require-uncached@1.0.2
| | +-- caller-path@0.1.0
| | | `-- callsites@0.2.0
| | `-- resolve-from@1.0.1
| +-- shelljs@0.6.1
| +-- strip-bom@3.0.0
| +-- strip-json-comments@1.0.4
| +-- table@3.7.8
| | +-- bluebird@3.4.3
| | +-- slice-ansi@0.0.4
| | +-- tv4@1.2.7
| | `-- xregexp@3.1.1
| +-- text-table@0.2.0
| `-- user-home@2.0.0
|   `-- os-homedir@1.0.1
+-- eslint-config-airbnb@10.0.1
| `-- eslint-config-airbnb-base@5.0.3
+-- eslint-plugin-flowtype@2.11.4
+-- eslint-plugin-import@1.14.0
| +-- builtin-modules@1.1.1
| +-- contains-path@0.1.0
| +-- doctrine@1.2.3
| +-- es6-map@0.1.4
| | +-- d@0.1.1
| | +-- es5-ext@0.10.12
| | +-- es6-iterator@2.0.0
| | +-- es6-symbol@3.1.0
| | `-- event-emitter@0.3.4
| +-- es6-set@0.1.4
| +-- eslint-import-resolver-node@0.2.3
| | `-- resolve@1.1.7
| +-- lodash.cond@4.5.2
| +-- lodash.endswith@4.2.1
| +-- lodash.find@4.6.0
| +-- lodash.findindex@4.6.0
| +-- object-assign@4.1.0
| +-- pkg-dir@1.0.0
| | `-- find-up@1.1.2
| |   +-- path-exists@2.1.0
| |   `-- pinkie-promise@2.0.1
| |     `-- pinkie@2.0.4
| `-- pkg-up@1.0.0
+-- eslint-plugin-jsx-a11y@2.1.0
| +-- damerau-levenshtein@1.0.0
| `-- jsx-ast-utils@1.3.1
+-- eslint-plugin-react@6.1.2
+-- koa@2.0.0
| +-- accepts@1.3.3
| | `-- negotiator@0.6.1
| +-- content-disposition@0.5.1
| +-- content-type@1.0.2
| +-- cookies@0.6.1
| | `-- keygrip@1.0.1
| +-- delegates@1.0.0
| +-- depd@1.1.0
| +-- destroy@1.0.4
| +-- error-inject@1.0.0
| +-- escape-html@1.0.3
| +-- fresh@0.3.0
| +-- http-assert@1.2.0
| | +-- deep-equal@1.0.1
| | `-- http-errors@1.4.0
| +-- http-errors@1.5.0
| | `-- setprototypeof@1.0.1
| +-- is-generator-function@1.0.3
| +-- koa-compose@3.1.0
| +-- koa-convert@1.2.0
| | `-- co@4.6.0
| +-- koa-is-json@1.0.0
| +-- mime-types@2.1.11
| | `-- mime-db@1.23.0
| +-- on-finished@2.3.0
| | `-- ee-first@1.1.1
| +-- only@0.0.2
| +-- parseurl@1.3.1
| +-- statuses@1.3.0
| `-- vary@1.1.0
+-- lodash@4.15.0
+-- mz@2.4.0
| +-- any-promise@1.3.0
| `-- thenify-all@1.6.0
|   `-- thenify@3.2.0
+-- performance-now@0.2.0
`-- superagent@2.2.0
  +-- component-emitter@1.2.1
  +-- cookiejar@2.1.0
  +-- extend@3.0.0
  +-- form-data@1.0.0-rc4
  | +-- async@1.5.2
  | `-- combined-stream@1.0.5
  |   `-- delayed-stream@1.0.0
  +-- formidable@1.0.17
  +-- methods@1.1.2
  +-- mime@1.3.4
  +-- qs@6.2.1
  `-- readable-stream@2.1.5
    +-- buffer-shims@1.0.0
    +-- core-util-is@1.0.2
    +-- process-nextick-args@1.0.7
    +-- string_decoder@0.10.31
    `-- util-deprecate@1.0.2