-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Conversation
Set the option `/* jslint browser: true */` by default, because Brackets is for "Coding the Web".
Copying my comment from the bug:
|
@peterflynn True... Should we have it as an option that users can enable? |
IMO, the best solution would be a configuration dialog, where users can enter their jslint settings by copying the generated directive from http://jslint.com |
Yes, if we can apply it as a global preference, then that would be pretty easy, if it ends up being a project or file preference then it will not be, since project/file preferences aren't ready yet. |
I agree, a global preference would be the way to start (until there is a proper Brackets way to store global preferences you can use |
The PreferenceStorage is used to save global preferences, which actually uses the local storage. It could also be used for files/projects, but there isn't a way to automatically delete them for deleted/unused project/files or show all of them and let the user delete them if he wants to. |
@jdiehl I'm not so sure about that one, since the JavaScript function takes in an object of options like I was thinking a dialog with checkboxes like those on the website; maybe that's a bit easier for the user as well? It would be easier to store the options as well (as JSON). |
You could easily parse the string from the website and create the JSON object for the function call, so that should not be a problem. Interaction-wise, I like utilizing existing resources if possible (the JSLint website and its form) and giving users powerful access to the low-level features (being able to copy&paste settings between different Brackets installations, etc.) without imposing a difficult interaction. The JSLint form could be easily linked or even embedded in the configuration dialog (we are working with web technology so everything is possible!). Additionally, there is no need to update the dialog if the JSLint options change. But, yes, a checkbox dialog would also work very well. |
@adrocknaphobia - @peterflynn pointed out that if we make this change, it will make our in-product JSLint inconsistent with what users would get from running it standalone. Would we still want this change in that case? |
Another option would be to implement support for the ".jslintrc" config file described here: https://groups.google.com/d/msg/brackets-dev/PGeYH5KTQNI/nd8B3xPmrhUJ. That wouldn't let you have "browser: true" as a default for all projects you open, but it would let you easily make it the default for a given project without having to add a JSLint settings block in every individual .js file. This would also be more flexible -- IMHO, given the strictness of JSLint, you will almost certainly want to have other settings set to non-default values too. If we took the prefs approach, unless we added UI for every JSLint setting, you'd still most likely need to as a JSLint settings block in every .js file to override those other settings. With a global project file, we could support project-global defaults for all settings with less effort. |
I really like the .jslintrc approach and the more editors / jslint tools support this the better it will become. The process could be as following:
The configuration dialog (if added) then simply allows users to edit these files ( To inform users about the difference between their jslint run in Brackets and an online run, the tool could run jslint a second time without the project/global options in the background or on demand (toggle button, tooltip, etc.). |
Add an option in a dialog to allow users to set a global JSLint directive. The dialog trigger is located in the *File > Set JSLint Global Directive...* menu.
Roll back ae5ecc4
Add an option in a dialog to allow users to set a global JSLint directive. The dialog trigger is located in the *File > Set JSLint Global Directive...* menu.
Sorry about the first commit - the formatting wasn't quite right. |
if (response === "ok" && typeof prefs !== "undefined") { | ||
localStorage["jslint-directive"] = prefs; | ||
var _obj = {}; | ||
var _props = prefs.replace("/*jslint ", "").replace(" */", "").split(', '); |
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 should use regular expressions to make the matching more reliable:
/^\s*\/\*\s*jslint\s*/
and /\/\s*\*\/\s*$/
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.
I'll fix that, thanks!
I think this is a good start, but we should wait for the core team to decide on the inconsistency issue before putting any more effort into this. |
@jdiehl I've implemented all of your suggestions locally (and everything's running great), but I won't push until that decision is made. Thanks! |
*/ | ||
function _savePrefs(prefs, response) { | ||
if (response === "ok" && typeof prefs !== "undefined") { | ||
localStorage["jslint-directive"] = prefs; |
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.
Use the preference storage here: _prefs.setValue("directive", prefs)
and _prefs.getValue("directive")
to retrieve them. You can set a default value changing to defaultPrefs = { enabled: true, directive: "" }
.
@peterflynn @njx What do you guys think? |
Add dialog to JSLint allowing users to paste a default directive.
I find it annoying that I can't turn JSLint off, and there doesn't seem to be a simple way to close the JSLint pane when it pops up (no close box?). |
@isonno -- you can turn it off from View > Enable JSLint, though I agree that it's annoying that you can't just close the panel. We plan to improve the UI around this when we make linting an "official" feature (it's currently an "unofficial" feature that happens to be in your face by default :)) |
Marking PM since I won't be at the pull request review meeting tomorrow--need @adrocknaphobia's input on this. |
I've added a link to this from the 'Linting Configuration' user story. @alfredxing We may want nicer UI-driven configuration eventually, but IMHO this is still a useful step forward that would at least be nice as a stopgap. We're a little busy in the current sprint though, so we may not be able to merge this for another couple weeks. Bear with us! :-) |
Oops, actually sorry I misread the thread. It looks like this doesn't implement my and @jdiehl's suggestions about .jslintrc... so I am actually less positive on this than what I said above. @alfredxing would you be interested in taking a stab at .jslintrc support? (If so best to make a new branch so it's separate from this UI work). |
@peterflynn Sure. I have exams right now (they end Monday), but I'll get on to that right afterwards. |
I tried using |
To @adrocknaphobia due to [PM] tag. I'm not totally clear on what the status of this is from the comment thread--might want to ping @peterflynn to get his take. Once resolved, please ping the team to let us know that we should assign this. |
Related to issues adobe#3269, adobe#4210. Based on the discussion and suggestions in adobe#3310. If a project has a .jslint.json in its root, it gets loaded and passed to each JSLint run within the project. The configuration file gets reloaded each time it is saved or refreshed.
Related to issues adobe#3269, adobe#4210. Based on the discussion and suggestions in adobe#3310. If a project has a .jslint.json in its root, it gets loaded and passed to each JSLint run within the project. The configuration file gets reloaded each time it is saved or refreshed.
@dangoor @peterflynn - do you think this is obsolete now that we have preferences for it? It's not exactly .jslintrc support but it allows you to configure jslint from the prefs file. |
It also should be pretty easy to write an extension to support |
@TomMalbran That seems like a good thing to incorporate into the main JSLint extension. If it sees a .jslintrc, it should prefer those settings over the ones in .brackets.json. @njx looking at the original description of this issue, I think this one is done because we have done exactly what the issue is requesting. |
Got it. Closing. |
Set the option
/* jslint browser: true */
by default,because Brackets is for "Coding the Web".
Addresses issue #3269