AtomLinter / linter-foodcritic

Atom linter provider for foodcritic
MIT License
1 stars 5 forks source link

Filter lint messages to only current file #35

Closed Yasumoto closed 4 years ago

Yasumoto commented 8 years ago

Although #18 correctly isolated the file to check, foodcritic still outputs messages for other files.

This filters all messages to only look at ones that pertain to the current file.

Arcanemagus commented 8 years ago

Wouldn't a better solution be to change this to a project scoped linter and show the messages, instead of just discarding them?

Yasumoto commented 8 years ago

That seems like the correct long-term solution, but as it stands now I'm not able to get any lint messages if (for instance) a dependency has an error on line 71 and my current file only has 50 lines.

I could circle back in a few days with an updated if you preferred that solution, but would need to dig into Atom's linting a bit first.

Arcanemagus commented 8 years ago

Make the above change and change the scope to project, that should do it. (And take out the filtering, obviously.)

Yasumoto commented 8 years ago

Hm, still getting the error with the posted diff. I'll take a little bit of time later this evening to dig in, since now I'm curious what I'm missing ๐Ÿ˜„

Error: Line number (77) greater than maximum line (50)
    at Object.rangeFromLineNumber (/Users/jmsmith/.atom/packages/linter-foodcritic/node_modules/atom-linter/lib/index.js:178:11)
    at /Users/jmsmith/.atom/packages/linter-foodcritic/lib/main.coffee:54:30
    at run (/Users/jmsmith/.atom/packages/go-quick-import/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:89:22)
    at /Users/jmsmith/.atom/packages/go-quick-import/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:102:28
    at flush (/Users/jmsmith/.atom/packages/go-quick-import/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)
    at doNTCallback0 (node.js:443:9)
    at process._tickCallback (node.js:372:13)
Yasumoto commented 8 years ago

Aha- this is because of the call to rangeFromLineNumber. Not sure how you'd like to approach it, some options are either in-line that function or coordinate an atom-linter release which takes a path name instead of textEditor.

Arcanemagus commented 8 years ago

Hmmmmm, if the file isn't the currently open file, maybe just return a range of a single character instead of using rangeFromLineNumber? If the user opens the file then the first lint will turn that into a full line selection as the TextEditor will then be available. The list won't change too much since it only shows the start point of the range.

Arcanemagus commented 6 years ago

Are you still interested in working on this @Yasumoto?

Yasumoto commented 6 years ago

Howdy @arcanemagus! Sorry for going quiet, Iโ€™m pretty swamped so wonโ€™t have cycles to fix this up. Please feel free to either close or carry forward! ๐Ÿ™‡โ€โ™‚๏ธ