Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Question regarding to the configuration with webpack 2 and eslint-plugin-import #22

Closed
hung-phan opened this issue Aug 8, 2016 · 8 comments

Comments

@hung-phan
Copy link

Hi there,

Thanks for this project. I ran into a problem with the configuration but don't know how to fix it yet. It used to work with the old version of eslint-plugin-import or this version of eslint-import-resolver-babel-module-alias. Any idea on this? My current configuration is:

{
  "extends": "airbnb",
  "parser": "babel-eslint",
  "plugins": ["mocha", "flowtype"],
  "env": {
    "mocha": true,
    "browser": true,
    "node": true
  },
  "rules": {
    "max-len": 0,
    "no-param-reassign": 0,
    "mocha/no-exclusive-tests": 2,
    "global-require": 0,
    "no-underscore-dangle": 0,
    "import/no-extraneous-dependencies": 0,
    "import/no-named-as-default": 0,
    "react/require-extension": 0,
    "react/jsx-filename-extension": 0,
    "flowtype/define-flow-type": 1,
    "flowtype/space-after-type-colon": [1, "always"],
    "flowtype/space-before-type-colon": [1, "never"],
    "flowtype/type-id-match": [1, "^([A-Z][a-z0-9]+)+Type$"],
    "flowtype/use-flow-type": 1
  },
  "settings": {
    "import/resolver": {
      "webpack": {},
      "babel-module-alias": {}
    }
  }
}
{
  "presets": ["es2015", "react", "stage-0"],
  "plugins": [
    "transform-runtime",
    ["module-alias", [
      { "src": "./app", "expose": "app" },
      { "src": "./config", "expose": "config" },
      { "src": "./app/client", "expose": "client" },
      { "src": "./app/server", "expose": "server" }
    ]]
  ],
  "env": {
    "development": {
      "plugins": [
        ["react-transform", {
          "transforms": [{
            "transform": "react-transform-hmr",
            "imports": ["react"],
            "locals": ["module"]
          }, {
            "transform": "react-transform-catch-errors",
            "imports": ["react", "redbox-react"]
          }]
        }]
      ]
    },
    "production": {
      "plugins": [
        "transform-react-constant-elements",
        "transform-react-inline-elements",
        "transform-react-remove-prop-types"
      ]
    },
    "test": {
      "plugins": [
        "rewire"
      ]
    }
  }
}

My issue is hung-phan/koa-react-isomorphic#36

@tleunen
Copy link
Owner

tleunen commented Aug 8, 2016

Thanks @hung-phan, I'll run some test later today to see what's wrong. I don't see any errors in your config though.

Could you try with the version 1.4.2 instead of 1.5?

@hung-phan
Copy link
Author

Ok, @tleunen. Currently, I have this error with eslint-plugin-import.

screen shot 2016-08-08 at 8 31 00 pm

@hung-phan
Copy link
Author

Oh, @tleunen. I tested it with v1.4.2 and it worked as expected

@tleunen
Copy link
Owner

tleunen commented Aug 8, 2016

Thanks for the confirmation. I'll double check this with your configuration but it seems there's something wrong when trying to merge the configuration from the dev/test/prod environment with the default one.

@tleunen tleunen closed this as completed in 50f4f6e Aug 9, 2016
@tleunen
Copy link
Owner

tleunen commented Aug 9, 2016

Thank you @hung-phan for reporting the issue, and by providing your repo in which the issue could easily be reproduced. I've fixed it in 1.5.1 so you can update the version if you want :)
I've tested it in your repo and the linting works with 1.5.1 ;)

@hung-phan
Copy link
Author

So great. Thanks @tleunen.

@jDeppen
Copy link

jDeppen commented Aug 12, 2016

I'm having a similar issue. Do you see anything I should do differently? Thanks

common, pages, and content (directories) are throwing errors.
error 'pages' should be listed in the project's dependencies. Run 'npm i -S pages' to add it

error Unable to resolve path to module 'content/container' import/no-unresolved
('container' is a file in the content directory)

{
  presets: ['es2015', 'stage-0', 'react'],
  plugins: [
    ['module-alias', [
      { expose: 'testHelper', src: './testHelper' },
      { expose: 'content',    src: './content' },
      { expose: 'common',     src: './content/common' },
      { expose: 'pages',      src: './content/body/main/pages' },
      { expose: 'services',   src: './services' },
      { expose: 'startup',    src: './startup' }
    ]]
  ]
}
{
  parser: 'babel-eslint',
  env: {
    es6: true,
    browser: true,
    mocha: true.
  },
  parserOptions: {
    ecmaVersion: 6,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true,
      experimentalObjectRestSpread: true,
    }
  },
  plugins: [
    'react',
  ],
  extends: [
    'airbnb',
    'eslint:recommended',
    'plugin:react/recommended',
    'standard',
  ],
  rules: { // 0: disabled, 1: warn, 2: error
    'import/no-unresolved': [2, {
      ignore: ['content', 'common', 'pages'] // this is my current workaround
    }],
    'comma-dangle' : [2, 'always-multiline'],
    'no-console': [2, {allow: ['warn', 'error']}],
    'no-extra-semi': 2,
    'curly': [2, 'all'],
    'default-case': 'error',
    'jsx-quotes': [2, 'prefer-single'],
    'react/jsx-boolean-value': [2, 'always'], // <Hello personal={true} /> not <Hello personal />
    'react/jsx-closing-bracket-location': [2, {selfClosing: 'line-aligned', nonEmpty: 'line-aligned'}],
    'react/jsx-curly-spacing': [2, 'never', {'allowMultiline': false}],
    'react/jsx-max-props-per-line': [2, {maximum: 1}],
    'react/self-closing-comp': 2,
    'react/sort-prop-types': [2, {ignoreCase: true}],
    'react/sort-comp': 2,
  },
  settings: {
    'import/resolver': {
      webpack: { config: 'webpack.client.base.config.js' },
      'babel-module-alias': {},
    },
  },
}
    "eslint": "^3.2.2",
    "eslint-config-airbnb": "^10.0.0",
    "eslint-config-standard": "^5.3.5",
    "eslint-import-resolver-babel-module-alias": "^1.5.1",
    "eslint-import-resolver-webpack": "^0.5.1",
    "eslint-plugin-import": "^1.13.0",
    "eslint-plugin-jsx-a11y": "^2.1.0",
    "eslint-plugin-promise": "^2.0.1",
    "eslint-plugin-react": "^6.0.0",
    "eslint-plugin-standard": "^2.0.0",

Thanks!

@tleunen
Copy link
Owner

tleunen commented Aug 13, 2016

Maybe a conflict with your webpack resolver? If you can setup a small repo which reproduce the issue, it could help :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants