Conversation
lib/lint/reporter/process-warns.js
Outdated
| var isChildProcess = typeof process.send == 'function'; // child process has send method | ||
| var collectFiles = require('./collectFiles'); | ||
|
|
||
| module.exports = function(flow, options){ |
There was a problem hiding this comment.
The interface was changed.
Have you considered adding [js]docs? Like what kind of objects should be flow and options now.
There was a problem hiding this comment.
This module should be untouched (see below).
lib/lint/index.js
Outdated
| } | ||
|
|
||
| cursor.linkTo.forEach(function(link){ | ||
| // prevent to handling files that already handled |
There was a problem hiding this comment.
prevent to handling files that are already handled
291afb4 to
b241c96
Compare
e902dad to
f1528ff
Compare
|
Now we supports: And <b:define name="someState" type="enum" values="prop1 prop2"/>
<div>
{l10n:enum.{someState}}
</div>
|
a8e1778 to
8460b42
Compare
lib/lint/command.js
Outdated
| .option('--no-color', 'Suppress color output') | ||
| .option('--silent', 'No any output') | ||
|
|
||
| .option('--warn-unused-files <base>', 'Warn about unused files in specified path. Do not use with --js-cut-dev. It might cause incorrect result') |
There was a problem hiding this comment.
.option('--warn-unused-files <dir>', 'Warn about unused files for specified path. Avoid using with --js-cut-dev since it might cause to incorrect results')
lib/common/files.js
Outdated
| */ | ||
|
|
||
| function File(manager, cfg){ | ||
| this.uniqueId = lastFileId++; |
lib/common/files.js
Outdated
| this.readInfo = []; | ||
|
|
||
| // helpers | ||
| this.unixpath = unixpath; |
| while (cursor = stack.pop()) | ||
| { | ||
| // mark file as handled | ||
| handled[cursor.uniqueId] = true; |
There was a problem hiding this comment.
I thought about Map, but it seems slow
But ok, I'll use it
lib/lint/index.js
Outdated
| function(flow){ | ||
| flow.result = require('./reporter/process-warns')(flow.warns, options.filter); | ||
| if (options.warnUnusedFiles) | ||
| collectUsed.files(flow); |
There was a problem hiding this comment.
Bad pattern: function has a hidden side effect. As I realised it adds usedFiles to flow – it's confusing and should be explicit.
lib/lint/reporter/process-warns.js
Outdated
| var isChildProcess = typeof process.send == 'function'; // child process has send method | ||
| var collectFiles = require('./collectFiles'); | ||
|
|
||
| module.exports = function(flow, options){ |
There was a problem hiding this comment.
This module should be untouched (see below).
lib/lint/collectUsed/files.js
Outdated
| } | ||
| }); | ||
|
|
||
| flow.usedFiles = { |
There was a problem hiding this comment.
Should returns something rather than assign to flow.
lib/lint/collectUsed/files.js
Outdated
| return file.filename && (basePath + file.filename).indexOf(collectPath + '/') === 0; | ||
| } | ||
|
|
||
| module.exports = function collectUsedFiles(flow){ |
There was a problem hiding this comment.
There is much simplier way to find used files for some path:
var usedFiles = flow.files.queue
.filter(function(file) {
return file.fsFilename.indexOf(flow.options.warnUnusedFiles + '/') === 0;
})
.map(...);
lib/lint/index.js
Outdated
| if (options.warnUnusedFiles) | ||
| collectUsed.files(flow); | ||
| }, | ||
| function(flow){ |
There was a problem hiding this comment.
No need for two functions here.
lib/lint/index.js
Outdated
| var command = require('./command'); | ||
| var chalk = require('chalk'); | ||
| var isChildProcess = typeof process.send == 'function'; // child process has send method | ||
| var collectUsed = { |
There was a problem hiding this comment.
l10n will be here soon :)
- decoupled flow and collectors - clear reporters
| } | ||
|
|
||
| // warn about unused files | ||
| for (var unusedFile in unusedFiles) |
There was a problem hiding this comment.
I believe this loop doesn't needed and unusedFiles map is redundant
| var collectedFiles = collectFiles(basePath); | ||
|
|
||
| usedFilesInfo.items.forEach(function(filename){ | ||
| usedFiles[usedFilesInfo.basePath + filename] = true; |
There was a problem hiding this comment.
Why not delete collectedFiles[usedFile] here? usedFiles is redundant
There was a problem hiding this comment.
cause it will affect flow.usedFiles
seems like it's not good
| delete collectedFiles[usedFile]; | ||
|
|
||
| for (var unusedName in collectedFiles) { | ||
| unusedName = unusedName.slice(process.cwd().length); |
There was a problem hiding this comment.
require('path').relative(...) ?
Merge after basisjs/basisjs#163 otherwise the linter will show the wrong result for
<b:style src="./some.css"/>