ESLint + Stimulus


#1

As a Rails dev needing somewhat sophisticated js behavior (but nothing SPA-like) I’m very happy about Stimulus. Thanks!!!

I’ve got a 10-year old open source rails app that I’m just starting to convert from lowpro behaviors (!?!) to stimulus.

I’m catching up on es6 in general and I’m wondering what linting people are using on their controllers.

I’m getting warnings for action methods that don’t use this (it wants static to be used). This makes sense to me (kind of) — I haven’t yet fleshed some of them out. But it got me wondering what people’s eslintrc looks like for their stimulus projects. Right now this app is using airbnb’s config…

{
  "parser": "babel-eslint",
  "extends": "airbnb", 
  "rules": {
    "strict": 0,
    "semi": 0,
    "no-console": 0
  },
  "env": {
    "browser": true
  }
}

Curious what others are doing…


#2

We use babel-eslint too but without airbnb's rules. I’m guessing airbnb is where the warnings are coming from?

{
  "parser": "babel-eslint",
  "extends": "eslint:recommended",
  "rules": {
    "semi": ["error", "never"],
    "quotes": ["error", "double"],
    "no-unused-vars": ["error", { "vars": "all", "args": "none" }],
    "no-trailing-spaces": ["error"],
    "no-multiple-empty-lines": ["error", { "max": 2 }],
    "prefer-const": ["error"],
    "getter-return": ["error"],
    "curly": ["error", "multi-line"]
  },
  "env": {
    "browser": true,
    "node": true,
    "es6": true
  }
}

#3

Thanks for sharing! Interesting…