Skip to content
Ember CLI addon for linting Ember projects with ESLint
JavaScript HTML
Branch: master
Clone or download
Latest commit af82a50 Aug 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
blueprints/ember-cli-eslint
config ensure tests are run Oct 17, 2018
node-tests
tests Get tests passing again Oct 17, 2018
vendor Initial Commit from Ember CLI v0.1.12 Feb 14, 2015
.bowerrc Initial Commit from Ember CLI v0.1.12 Feb 14, 2015
.editorconfig Update to ember-cli 2.13 May 1, 2017
.ember-cli Initial Commit from Ember CLI v0.1.12 Feb 14, 2015
.eslintignore Upgrade to ember-cli 3.4 via ember-cli-update Oct 17, 2018
.eslintrc.js
.gitignore Upgrade to ember-cli 3.4 via ember-cli-update Oct 17, 2018
.npmignore Upgrade to ember-cli 3.4 via ember-cli-update Oct 17, 2018
.template-lintrc.js Upgrade to ember-cli 3.4 via ember-cli-update Oct 17, 2018
.travis.yml TravisCI: Remove deprecated `sudo: false` option Dec 1, 2018
.watchmanconfig update to ember-cli@v2.3 Feb 27, 2016
CHANGELOG.md
LICENSE.md
README.md Link to @typescript/eslint-parser instead of typescript-eslint-parser Jun 17, 2019
ember-cli-build.js cleanup Oct 17, 2018
index.js Fix `VersionChecker` construction Jan 18, 2019
package.json Build(deps-dev): Bump ember-cli-babel from 7.10.0 to 7.11.0 Aug 29, 2019
testem.js Do not fork tap reporter / match regexes Oct 17, 2018
yarn.lock Build(deps-dev): Bump ember-cli-babel from 7.10.0 to 7.11.0 Aug 29, 2019

README.md

ember-cli-eslint

Latest NPM release TravisCI Build Status Ember Observer Score

ESLint for Ember CLI apps and addons

Installation

ESLint 4 (for Node 4 and above):

ember install ember-cli-eslint@4

ESLint 3 (for Node 4 and above):

ember install ember-cli-eslint@3

ESLint 2 (for Node 0.10 and above):

ember install ember-cli-eslint@2

After installation, an .eslintrc.js file will be placed in both the root of your project and the /tests directory.

Furthermore, a .eslintignore file can be used to exclude files from linting while the linter is running. Its syntax is identical to .gitignore files.

Disabling JSHint

Congratulations! You've made the leap into the next generation of JavaScript linting. At the moment, however, ember-cli defaults to generating applications and addons with a jshint configuration.

If you notice the two awkwardly running side by side, click here!

ember-cli >= 2.5.0

As of ember-cli v.2.5.0, jshint is provided through its own ember-cli-jshint addon. Running npm uninstall --save-dev ember-cli-jshint, in addition to removing any .jshintrc files from your project should guarantee that its behavior is disabled.

ember-cli < 2.5.0

Controlling linting is a bit trickier on versions of ember-cli prior to 2.5.0. Within your ember-cli-build.js file, ember-cli-qunit or ember-cli-mocha can be configured to have their default linting process disabled during:

module.exports = function(defaults) {
  const app = new EmberApp(defaults, {
    'ember-cli-qunit': {
      useLintTree: false
    }
  });
};

or

module.exports = function(defaults) {
  const app = new EmberApp(defaults, {
    'ember-cli-mocha': {
      useLintTree: false
    }
  });
};

Alongside this setting, the hinting property can then be used to enable/disable globally:

const isTesting = process.env.EMBER_ENV === 'test';

module.exports = function(defaults) {
  const app = new EmberApp(defaults, {
    hinting: !isTesting,
  });
};

Usage

ESLint will be run by ember-cli-qunit or ember-cli-mocha automatically when you run ember test. If ESLint is not being run automatically, try updating your ember-cli and/or ember-cli-qunit/ember-cli-mocha dependencies.

Configuration

ember-cli-eslint can be configured through the eslint key in your ember-cli-build.js file:

let app = new EmberApp(defaults, {
  eslint: {
    testGenerator: 'qunit',
    group: true,
    rulesDir: 'eslint-rules',
    extensions: ['js'],
  }
});
  • testGenerator is automatically detected if ember-qunit/ember-cli-qunit or ember-mocha/ember-cli-mocha are used, but can also be set to qunit and mocha manually.

  • group can be set to false to go back to the previous behavior where every generated test was contained in its own separate module.

  • rulesDir is the name of the directory for your custom eslint rules. It defaults to eslint-rules.

  • extensions is an array containing the file extensions to lint. If you want to lint JavaScript and TypeScript files for example it should be set to ['js', 'ts']. NOTE: If you add Typescript files @typescript/eslint-parser has to be installed and specified as the parser. For more information take a look at the @typescript/eslint-parser

On Build Files

Please note that if you are using this to lint files which are part of the build process (ie. index.js, ember-cli-build.js, config/), whether in an application or as part of an addon, they will not be linted. It is recommended that eslint is setup separately to lint these files and can be setup as an npm script and run as part of a CI process.

Contributing

Installation

  • git clone this repository
  • cd ember-cli-eslint
  • npm install
  • bower install

Running

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server
  • ember try:each

Linting

  • npm run lint:hbs
  • npm run lint:js
  • npm run lint:js -- --fix

Running the dummy application

For more information on using ember-cli, visit https://ember-cli.com/.

License

This project is licensed under the MIT License.

You can’t perform that action at this time.