- 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'],
}
});
- disable jshint https://github.com/ember-cli/ember-cli-eslint#disabling-jshint
yarn add --dev prettier eslint-plugin-prettier
- prettier pluginyarn add --dev eslint-config-prettier
// 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"
]
}
}
-
editor integration notes https://github.com/prettier/prettier#editor-integration
-
Running prettier on all existing files - did prettify all local files for me, but ended up with an error.
-
yarn add eslint-plugin-ember-suave --dev
// .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'
}
};
Looks like Ember Suave needs to be added as an Eslint extension in
.eslintrc.js