I'm using EmberJS
v1.13 and currently running ember test
uses JSHint
to detect possible errors in the code and I need to tell Ember
to use ESLint
instead.
Any ideas on what I should do?
I'm using EmberJS
v1.13 and currently running ember test
uses JSHint
to detect possible errors in the code and I need to tell Ember
to use ESLint
instead.
Any ideas on what I should do?
you could use the following tools:
1. For the browser: link
2. Using Visual Studio Code, you add an extension: go to the marketplace and install the Ember cli (it will help you)
3. Installing Ember CLI ESLint link
// ember-cli-build.js (or Brocfile.js on older versions of ember-cli)
var path = require('path');
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
// 'npm install --save-dev js-string-escape'
var jsStringEscape = require('js-string-escape');
var app = new EmberApp({
eslint: {
testGenerator: eslintTestGenerator
}
});
function render(errors) {
if (!errors) { return ''; }
return errors.map(function(error) {
return error.line + ':' + error.column + ' ' +
' - ' + error.message + ' (' + error.ruleId +')';
}).join('\n');
}
// Qunit test generator
function eslintTestGenerator(relativePath, errors) {
var pass = !errors || errors.length === 0;
return "import { module, test } from 'qunit';\n" +
"module('ESLint - " + path.dirname(relativePath) + "');\n" +
"test('" + relativePath + " should pass ESLint', function(assert) {\n" +
" assert.ok(" + pass + ", '" + relativePath + " should pass ESLint." +
jsStringEscape("\n" + render(errors)) + "');\n" +
"});\n";
}
// Mocha test generator
function eslintTestGenerator(relativePath, errors) {
var pass = !errors || errors.length === 0;
return "import { describe, it } from 'mocha';\n" +
"import { assert } from 'chai';\n" +
"describe('ESLint - " + path.dirname(relativePath) + "', function() {\n" +
" it('" + relativePath + " should pass ESLint', function() {\n" +
" assert.ok(" + pass + ", '" + relativePath + " should pass ESLint." +
jsStringEscape("\n" + render(errors)) + "');\n" +
" });\n});\n";
}
You could use ember-cli-eslint , installing:
ESLint 3 (for Node 4 or higher):
ember install ember-cli-eslint@3
ESLint 2 (for Node 0.10 or greater):
ember install ember-cli-eslint@2
Then you will delete jshint
running:
npm uninstall --save-dev ember-cli-jshint
And you will delete all .jshintrc
files left in the project.