Provides the universal configuration for eslint at Squarespace.
JavaScript
Latest commit f8c48d8 Jan 19, 2017 @georgezzhang georgezzhang 1.0.1
Permalink
Failed to load latest commit information.
react Fixing old rule. Dec 16, 2016
test Initial commit. Dec 16, 2016
vanilla Initial commit. Dec 16, 2016
.eslintrc Initial commit. Dec 16, 2016
.gitignore Initial commit. Dec 16, 2016
LICENSE.txt License Dec 19, 2016
README.md Fixing Squarespace link in readme Jan 19, 2017
index.js Initial commit. Dec 16, 2016
package.json 1.0.1 Jan 19, 2017

README.md

eslint-config-squarespace

Provides the universal configuration for eslint at Squarespace.

Installation

Without React

$ npm install --save-dev eslint-config-squarespace babel-eslint

Then:

add "extends": "eslint-config-squarespace" to your .eslintrc

Example .eslintrc

{
  "extends": "eslint-config-squarespace/vanilla",
  "env": {
    "browser": true,
    "mocha": true,
    "node": true
  }
}

With React

$ npm install --save-dev eslint-config-squarespace babel-eslint eslint-plugin-react

Example .eslintrc

{
  "extends": "squarespace",
  "env": {
    "browser": true,
    "mocha": true,
    "node": true
  },
  "plugins": [
    "react"
  ]
}

Integrating with Webpack

You may add eslint config to a webpack build process by using a preloader and some eslint config. There should be no need to reference this config file provided the .eslintrc 'extends' property is set.

$ npm install --save eslint-loader
// webpack.config.js
module: {
  eslint: {
    configFile: path.join(pathsToESlint, '.eslintrc'),
    failOnError: true
  },
  module: {
    preLoaders: [
      {
        test: /\.jsx?$/,
        loader: 'eslint',
        include: pathsToFiles
      }
    ],
    ..
  }

Troubleshooting

Webpack

The webpack plugin for pre-linting is notoriously slow, because it can not leverage and form of caching available to either eslint or webpack. If it is too slow, try moving it to the npm command that starts the webpack build.

Global Eslint

Global CLI installations of eslint cannot find local modules. This is expected behavior. Tools or scripts that rely on such global installations must be rewritten or modified to find the correct node_modules folder.

Fix Syntastic for Vim

If you are using syntastic, adding the following to your .vimrc should fix eslint.

" Kludge to fix global/local.
let g:syntastic_javascript_checkers = ['eslint']

let local_eslint = finddir('node_modules', '.;') . '/.bin/eslint'
if matchstr(local_eslint, "^\/\\w") == ''
    let local_eslint = getcwd() . "/" . local_eslint
endif
if executable(local_eslint)
    let g:syntastic_javascript_eslint_exec = local_eslint
endif

License

Apache-2 copyright Squarespace