Skip to content

Instantly share code, notes, and snippets.

@edygar
Last active May 30, 2016 22:57
Show Gist options
  • Save edygar/76d4ab7284511b6add7604ddaa5a1bb2 to your computer and use it in GitHub Desktop.
Save edygar/76d4ab7284511b6add7604ddaa5a1bb2 to your computer and use it in GitHub Desktop.
My prefered ESlintrc
{
"extends": "eslint-config-airbnb",
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module"
},
"ecmaFeatures": {
"classes": true,
"jsx": true
},
"env": {
"browser": true,
"node": true,
"mocha": true,
"es6": true
},
"rules": {
"strict": 0,
"indent": [2, 2],
"react/prefer-stateless-function": 0,
"import/named": 2,
"comma-dangle": 0,
"no-console": 0,
"no-alert": 0
},
"plugins": [
"babel",
"react",
"import",
"jsx-a11y"
]
}

.eslintrc

This settings extends airbnb's with some important features and integration with webpack.

Sample

Dependencies:

Getting Started

Paste the .eslintrc on project's root directory and lnstall ESLint, Airbnb's config and its peerDependencies and dependencies:

npm install --save-dev eslint@^2.9.0 babel-eslint@^6.0.4 [email protected] [email protected] eslint-config-airbnb@^8.0.0 eslint-plugin-babel@^3.2.0 eslint-plugin-import@^1.7 eslint-plugin-jsx-a11y@^1.0.4 eslint-plugin-react@^5.0.1

Node Support

Install eslint-import-resolver-node, the default resolver for imports and exports.

node install --save-dev eslint-import-resolver-node@^0.2.0

Then set up the .eslintrc file

+  "settings": {
+    "import/resolver": "node"
+  }

Webpack Support

Install eslint-import-resolver-webpack@^0.2.4, a Webpack resolver for imports and exports. Then, install and eslint-loader^1.3.0, a Webpack loader to display on screen ESLint analysis.

Install the packages:

 npm install --save-dev [email protected] eslint-loader@^1.3.0

After, set up the eslint preloader to webpack dev config, as follows:

  module: {
+    preLoaders: [
+      {test: /\.js$/, loader: 'eslint-loader', exclude: /node_modules/}
+    ],
    loaders: [
      { test: /\.js$/, exclude: /node_modules/, loaders: [ 'babel' ]}
    ]
  }

Include the Webpack resolver to .eslintrc settings:

+  "settings": {
+    "import/resolver": {
+      "webpack": { "config": "config/webpack.config.dev.js" }
+    }
+  }
@igorvieira
Copy link

In node suporte
change for :
npm install --save-dev eslint-import-resolver-node@^0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment