-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade broccoli-filter #14
Merged
jonathanKingston
merged 4 commits into
ember-cli:master
from
nickiaconis:filter-upgrade
Mar 10, 2016
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
test/fixture/* | ||
build/* | ||
tmp/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- '0.10' | ||
- 'stable' | ||
before_install: | ||
- npm install -g broccoli-cli | ||
- npm install -g broccoli-cli |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "nightmare-mode/node" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function noNewLineBeforeReturn() { | ||
const foo = 'foo'; | ||
|
||
console.log(foo); | ||
} | ||
|
||
noNewLineBeforeReturn(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const broccoli = require('broccoli'); | ||
const eslint = require('../../index'); | ||
|
||
module.exports = function runEslint(path, _options) { | ||
const options = _options || {}; | ||
const buildLog = []; | ||
const consoleLog = console.log; | ||
|
||
// stub console.log so we can get the formatter's output | ||
console.log = function appendToBuildLog(...args) { | ||
const text = args.join(' '); | ||
|
||
buildLog.push(text); | ||
}; | ||
|
||
// default options | ||
options.format = options.format || 'eslint/lib/formatters/compact'; | ||
options.options = options.options || {}; | ||
options.options.ignore = options.options.ignore || false; | ||
|
||
const tree = eslint(path, options); | ||
const builder = new broccoli.Builder(tree); | ||
const promise = builder.build().then(function builderThen() { | ||
return buildLog.join('\n'); | ||
}); | ||
|
||
promise.finally(function builderCleanup() { | ||
builder.cleanup(); | ||
|
||
// restore the original console.log | ||
console.log = consoleLog; | ||
}); | ||
|
||
return promise; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const rimraf = require('rimraf'); | ||
const expect = require('chai').expect; | ||
const runEslint = require('./helpers/run-eslint'); | ||
const FIXTURES = 'test/fixture'; | ||
const CAMELCASE = '(camelcase)'; | ||
const CONSOLE = '(no-console)'; | ||
const CUSTOM_RULES = 'testing custom rules'; | ||
const DOUBLEQUOTE = 'Strings must use doublequote.'; | ||
const FILEPATH = 'fixture/1.js'; | ||
|
||
afterEach(function afterEach() { | ||
rimraf.sync('temp'); | ||
rimraf.sync('broccoli-build.out'); | ||
}); | ||
describe('EslintValidationFilter', function describeEslintValidationFilter() { | ||
it('should report errors', function shouldReportErrors() { | ||
// lint test fixtures | ||
const promise = runEslint(FIXTURES); | ||
|
||
return promise.then(function assertLinting(buildLog) { | ||
expect(buildLog, 'Used eslint validation').to.have.string(CAMELCASE); | ||
expect(buildLog, 'Shows filepath').to.have.string(FILEPATH); | ||
expect(buildLog, 'Used relative config - console not allowed').to.have.string(CONSOLE); | ||
expect(buildLog, 'Used relative config - single quotes').to.not.have.string(DOUBLEQUOTE); | ||
expect(buildLog, 'No custom rules defined').to.not.have.string(CUSTOM_RULES); | ||
}); | ||
}); | ||
|
||
it('should accept rule paths', function shouldAcceptRulePaths() { | ||
// lint test fixtures using a custom rule | ||
const promise = runEslint(FIXTURES, { | ||
options: { | ||
rulePaths: ['conf/rules'] | ||
} | ||
}); | ||
|
||
return promise.then(function assertLinting(buildLog) { | ||
expect(buildLog, 'Used custom rule').to.have.string(CUSTOM_RULES); | ||
}); | ||
}); | ||
|
||
it('should reported errors', function shouldReportErrors() { | ||
const buildLog = fs.readFileSync('broccoli-build.out').toString(); | ||
const NOT_FOUND = -1; | ||
it('should accept config file path', function shouldAcceptConfigFile() { | ||
// lint test fixtures using a config file at a non-default path | ||
const promise = runEslint(FIXTURES, { | ||
options: { | ||
configFile: 'conf/eslint.json' | ||
} | ||
}); | ||
|
||
assert(buildLog.indexOf('Strings must use doublequote.') !== NOT_FOUND, 'Used eslint validation - strings'); | ||
assert(buildLog.indexOf('is not in camel case') !== NOT_FOUND, 'Used eslint validation - camel case'); | ||
assert(buildLog.indexOf('testing custom rules') !== NOT_FOUND, 'Used custom rulesdir rules'); | ||
assert(buildLog.indexOf('fixture/1.js') !== NOT_FOUND, 'Shows filepath'); | ||
return promise.then(function assertLinting(buildLog) { | ||
expect(buildLog, 'Used alternate config - console allowed').to.not.have.string(CONSOLE); | ||
expect(buildLog, 'Used alternate config - double quotes').to.have.string(DOUBLEQUOTE); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to assume that
inputTree
is thesrcDir
string. Isn'tinputTree
an object? This breaks the paths inprocessString
later on when we concatenate it torelativePath
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nickiaconis can this be addressed in #21? Pretty sure @teddyzeenny is right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. All the tests provide a string as the input node, so I overlooked the possibility that this could be a tree instance. Any ideas how to resolve this from a tree? My first thought is to recursively resolve the
_inputNodes
objects until we get a string, but this doesn't account for merge trees.