Skip to content

Commit

Permalink
Merge pull request #203 from t-sauer/extensions-config
Browse files Browse the repository at this point in the history
Make extensions configurable
  • Loading branch information
Turbo87 authored Jul 17, 2017
2 parents b2b1b4e + b59bbe1 commit 8c7220c
Show file tree
Hide file tree
Showing 7 changed files with 602 additions and 302 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ let app = new EmberApp(defaults, {
testGenerator: 'qunit',
group: true,
rulesDir: 'eslint-rules',
extensions: ['js'],
}
});
```
Expand All @@ -143,6 +144,8 @@ let app = new EmberApp(defaults, {
- `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`](https://github.com/eslint/typescript-eslint-parser)

### On Build Files

Please note that if you are using this to lint files which are part of the build
Expand Down
4 changes: 4 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ module.exports = function (defaults) {
options.eslint.group = false;
}

if (process.env['JSX']) {
options.eslint.extensions = ['js', 'jsx'];
}

var app = new EmberAddon(defaults, options);

/*
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = {
return ESLint.create(tree, {
testGenerator: this.options.testGenerator || this._testGenerator,
group: (this.options.group !== false) ? type : undefined,
extensions: this.options.extensions,

options: {
rulesDir: this.options.rulesDir || 'eslint-rules'
Expand Down
23 changes: 23 additions & 0 deletions node-tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ describe('ember-cli-eslint', function() {
.to.contain('ok 11 PhantomJS 2.1 - ESLint | tests: test-helper.js');
})
});

it('passes if jsx files are included', function() {
process.env['JSX'] = true;

return emberTest().then(function(result) {
expect(result.error).to.not.exist;
expect(result.stdout.match(/[^\r\n]+/g))
.to.contain('ok 1 PhantomJS 2.1 - ESLint | app: app.js')
.to.contain('ok 2 PhantomJS 2.1 - ESLint | app: controllers/thing.js')
.to.contain('ok 3 PhantomJS 2.1 - ESLint | app: models/thing.js')
.to.contain('ok 4 PhantomJS 2.1 - ESLint | app: resolver.js')
.to.contain('ok 5 PhantomJS 2.1 - ESLint | app: router.js')
.to.contain('ok 6 PhantomJS 2.1 - ESLint | app: routes/thing.jsx')
.to.not.contain('not ok 7 PhantomJS 2.1 - ESLint | app: unused.js');

expect(result.stdout.match(/[^\r\n]+/g))
.to.contain('ok 7 PhantomJS 2.1 - ESLint | tests: helpers/destroy-app.js')
.to.contain('ok 8 PhantomJS 2.1 - ESLint | tests: helpers/module-for-acceptance.js')
.to.contain('ok 9 PhantomJS 2.1 - ESLint | tests: helpers/resolver.js')
.to.contain('ok 10 PhantomJS 2.1 - ESLint | tests: helpers/start-app.js')
.to.contain('ok 11 PhantomJS 2.1 - ESLint | tests: test-helper.js');
})
});
});

function emberTest() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"test": "mocha node-tests --recursive"
},
"dependencies": {
"broccoli-lint-eslint": "^4.0.0",
"broccoli-lint-eslint": "^4.1.0",
"ember-cli-version-checker": "^2.0.0",
"rsvp": "^3.2.1",
"walk-sync": "^0.3.0"
Expand Down
4 changes: 4 additions & 0 deletions tests/dummy/app/routes/thing.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Ember from 'ember';

export default Ember.Route.extend({
});
Loading

0 comments on commit 8c7220c

Please sign in to comment.