Skip to content
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

Linting in addon #14

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,36 @@ module.exports = {

lintTree: function(type, tree) {
var mergedTrees;
var projectName = this.app.project.name();
var isAddon = (this.app.name !== projectName);

if (type === 'app') {
if (isAddon && tree.srcDir === projectName && type === 'addon') {
var treePaths = this.registry.app.treePaths;
var paths = [];

['addon-styles', 'styles'].forEach(function(subtree) {
var path = treePaths[subtree];

/* Use fs.statSync to check if the styles dir exists in
addon-name/addon/styles and addon-name/app/styles */

try {
var stats = fs.statSync(path);

if (stats.isDirectory()) {
paths.push(path);
}
}
catch (ignored) {}
});

mergedTrees = mergeTrees(paths.map((path) => {
return new Funnel(path);
}));

return new SassLinter(mergedTrees, this.sassLintOptions);
}
else if (!isAddon && tree.destDir === '/' && type === 'app') {
mergedTrees = mergeTrees([
new Funnel(this.app.trees.app, {
exclude: ['**/*.js']
Expand Down
7 changes: 6 additions & 1 deletion tests/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ function buildAndLint(sourcePath) {
trees: {
app: sourcePath, // Directory to lint
},
name: 'dummy',
project: {
name: () => 'dummy'
},
});

var node = linter.lintTree('app', {
tree: sourcePath
srcDir: sourcePath,
destDir: '/'
});

builder = new broccoli.Builder(node);
Expand Down