Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ember + ESLint + Prettier + Ember Suave
  • new ember app & yarn install
  • ember install ember-cli-eslint@4
// ember-cli-build.js
let app = new EmberApp(defaults, {
  eslint: {
    testGenerator: 'qunit',
    group: true,
    rulesDir: 'eslint-rules',
    extensions: ['js'],
  }
});
// eslintrc.js
module.exports = {
  root: true,
  parserOptions: {
    ecmaVersion: 2017,
    sourceType: 'module'
  },
  extends: ['prettier'],
  env: {
    browser: true
  },
  plugins: [
    "prettier"
  ],
  rules: {
    "prettier/prettier": "error"
  }
};
  • yarn add lint-staged husky --dev
// package.json
{
  "scripts": {
    "precommit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,json,css}": [
      "prettier --write",
      "git add"
    ]
  }
}
// .eslintrc.js
module.exports = {
  root: true,
  parserOptions: {
    ecmaVersion: 2017,
    sourceType: 'module'
  },
  extends: [
    'prettier'
  ],
  env: {
    browser: true
  },
  plugins: [
    "prettier"
  ],
  rules: {
    // Formatting
    'prettier/prettier': 'error',

    // ES6
    'arrow-parens': ['error', 'always'],
    'generator-star-spacing': ['error', {
      'before': false,
      'after': true
    }],
    'no-var': 'error',
    'object-shorthand': ['error', 'always'],
    'prefer-spread': 'error',
    'prefer-template': 'error',

    // Overrides for Ember
    'new-cap': ['error', {
      'capIsNewExceptions': ['A']
    }],

    'ember-suave/no-const-outside-module-scope': 'error',
    'ember-suave/no-direct-property-access': 'error',
    'ember-suave/prefer-destructuring': 'error',
    'ember-suave/require-access-in-comments': 'error',
    'ember-suave/require-const-for-ember-properties': 'error'
  }
};
@Matt-Jensen

This comment has been minimized.

Matt-Jensen commented May 28, 2018

Looks like Ember Suave needs to be added as an Eslint extension in .eslintrc.js

module.exports = {
  extends: [
    // ..
    'plugin:ember-suave/recommended'
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment