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

ESLintBear doesn't resolve relative impoarts #741

Closed
sils opened this issue Aug 31, 2016 · 8 comments
Closed

ESLintBear doesn't resolve relative impoarts #741

sils opened this issue Aug 31, 2016 · 8 comments

Comments

@sils
Copy link
Member

sils commented Aug 31, 2016

ESLintBear is used with stdin in coala to use the in memory file contents. HOwever imports seem to be relative in JS which means that ESLint things probably that they are relative to the CWD which leads to lots of false errors and not working imports.

type/bug area/lintbears importance/high difficulty/low probably

@gitmate-bot
Copy link
Collaborator

Thanks for reporting this issue! A coalaian will look at it soon.

@AbdealiLoKo
Copy link
Contributor

How can I reproduce this ?
When using a code like:

import addOne from './eslint_test_module';

addOne(2);

and

export function addOne(i) {
    return i + 1;
};

I get Parsing error: The keyword 'import' is reserved. It seems that eslint doesn't support ES6 imports yet[0]. And to use that you need to enable the babel loader[1]. Did you do all that ?

If yes, please share configs and steps to set up

[0] - https://medium.com/@tkssharma/eslint-in-react-babel-webpack-9cb1c4e86f4e#.x5p2kanc9
[1] - http://www.robinwieruch.de/the-soundcloud-client-in-react-redux/#babel

@sils
Copy link
Member Author

sils commented Aug 31, 2016

Ah we had a config. @oreqizer can we share your eslint config publicly or to him privately?

@oreqizer
Copy link
Contributor

oreqizer commented Sep 1, 2016

{
    "parser": "babel-eslint",
    "plugins": ["react", "flowtype"],
    "extends": "airbnb",
    "env": {
        "node": true,
        "browser": true
    },
    "rules": {
        // Flow
        // ---
        "flowtype/define-flow-type": "error", // teaches ESlint Flow types
        "no-duplicate-imports": "off", // we need to import types separately

        // Kiwi style
        // ---
        "semi": ["error", "never"],
        "indent": ["error", "tab"],
        "react/jsx-indent": ["error", "tab"],
        "react/jsx-indent-props": ["error", "tab"],
        "max-len": ["warn", { "code": 150 }], // will get reduced eventually
        "dot-notation": ["off"], // we use bracket notation for external inputs (API, url params, ...)
        "react/jsx-filename-extension": [1, { "extensions": [".js"] }],
        "new-cap": "off", // Because Immutable.js
        "no-underscore-dangle": "off", // __LOG
        // Strajk & Michael don't care
        "jsx-a11y/label-has-for": "off", // we put inputs into labels
        "one-var": ["off"], // we like this
        "one-var-declaration-per-line": ["off"], // we like this
        "no-else-return": ["off"], // everybody got his own taste
        "react/prop-types": ["off"],
        "import/prefer-default-export": ["off"],


        // known 'babel-eslint' bug
        // ---
        "generator-star-spacing": "off",


        // Fix gradually
        // ---
        "no-unused-expressions": "warn",
        "vars-on-top": "warn",
        "no-prototype-builtins": "warn",
        "no-unused-vars": "warn",
        "default-case": "warn",
        "radix": "warn", // Wanna use Number(…)
        "func-names": "warn",
        "no-mixed-operators": "warn",


        // Fix automatically someday
        // ---
        "object-shorthand": "off", // TODO: try `consistent-as-needed`
        "quotes": ["off", "double", "avoid-escape"],
        "no-trailing-spaces": "off",
        "no-var": "off",
        "quote-props": "off",
        "comma-dangle": "off",
        "object-curly-spacing": "off",
        "prefer-template": "off",
        "prefer-const": "off",
        "import/no-duplicates": "off",
        "padded-blocks": "off",
        "spaced-comment": "off",
        "import/imports-first": "off",
        "react/jsx-space-before-closing": "off",
        "jsx-a11y/img-has-alt": "off",
        "react/sort-comp": "off",
        "react/no-find-dom-node": "off",
        "react/no-string-refs": "off",
        // Codemod
        "react/prefer-stateless-function": "warn",
        "react/prefer-es6-class": "warn",
        "arrow-body-style": "off",
    },
}

@sils sils removed their assignment Sep 1, 2016
@sils
Copy link
Member Author

sils commented Sep 1, 2016

@oreqizer would you be willing to investigate this, write a test and fix so we can switch the project?

@oreqizer
Copy link
Contributor

oreqizer commented Sep 1, 2016

i'll try to look into it

@AbdealiLoKo AbdealiLoKo removed their assignment Sep 1, 2016
@sils
Copy link
Member Author

sils commented Sep 2, 2016

@oreqizer assigning you then, ping us if you need help or want to drop this!

@sils
Copy link
Member Author

sils commented Sep 2, 2016

From the discussions we had the most likely solution will be not using stdin to feed the file but give eslint the filename as an argument instead, then it should figure that out. Alternatively we could possibly give it the filename with an argument if eslint exposes that.

sils pushed a commit that referenced this issue Sep 11, 2016
Adds information about current file location for ESLint.
Aids in relative imports.

Fixes #741
gosom pushed a commit to gosom/coala-bears that referenced this issue Jul 15, 2017
Adds information about current file location for ESLint.
Aids in relative imports.

Fixes coala#741
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants