-
Notifications
You must be signed in to change notification settings - Fork 6
[WIP] issue #622 Disable lint by default #663 #2
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
base: interactive-linting
Are you sure you want to change the base?
Conversation
|
Nope, it's wrong. The only reason it works is because .bracket.json is not present |
humphd
left a comment
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.
Left some feedback. Let me know how you progress.
| "url": "https://github.com/mozilla/brackets.git", | ||
| "branch": "", | ||
| "SHA": "" | ||
| }, |
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.
You can do git checkout master src/config.json to get rid of this change.
| var preferencesID = "interactive-linter"; | ||
|
|
||
| var defaultPreferences = { | ||
| delay: 500, |
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.
These need to get indented 4-spaces.
| delay: 500, | ||
| enabled: false, | ||
| webworker: true, | ||
| javascript: "eslint" |
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 is wrong. If you look above at .brackets.json you'll see that it's an array of strings.
| _preferences.definePreferences("enabled", "boolean", defaultPreferences.disable); | ||
| _preferences.definePreferences("delay", "int", defaultPreferences.delay); | ||
| _preferences.definePreferences("webworker", "boolean", defaultPreferences.webworker); | ||
| _preferences.definePreferences("javascript", "string", defaultPreferences.javascript); |
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.
Also wrong here, you'll need to define an array of strings instead.
| _preferences.definePreferences("webworker", "boolean", defaultPreferences.webworker); | ||
| _preferences.definePreferences("javascript", "string", defaultPreferences.javascript); | ||
| } | ||
|
|
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.
Remove all this extra whitespace.
| */ | ||
| function appReady() { | ||
|
|
||
| loadPreferences(); |
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.
Remove the blank live above this, move it below.
humphd
left a comment
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.
Looking good. I left some notes about fixes to make, and also a way to have us load less code when the extension is disabled on startup.
| linterManager = require("linterManager"), | ||
| pluginManager = require("pluginManager"); | ||
|
|
||
|
|
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.
Get rid of this empty line.
| pluginManager = require("pluginManager"); | ||
|
|
||
|
|
||
| var defaultPreferences = { |
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 entire code block (line 25-34) is indented one tab stop too far. Make it line up with what's above and below it
| addGutter(currentEditor); | ||
| handleDocumentChange(); | ||
| } | ||
|
|
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.
Get rid of this blank line.
| */ | ||
| function appReady() { | ||
| loadPreferences(); | ||
| // Removes the default Brackets JSLint linter |
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.
Because we are going to disable everything by default, and because it will add a lot of network size when we first load the app, I think we should do lazy-loading of all the linting plugins. To do this will requires a few things:
- Move all of the code from 172 to 205 into a function named
init. Thisinitfunction will take care of loading all the plugins and registering them, as well as callingsetDocumentto enable any in the current editor. - After you call
loadPreferences()on 171, do anifcheck to see if theenabledpref is true, and if it is, callinit()immediately (i.e., if the user has the prefenabled=true, then we'll load all the plugins right now on startup). If it'sfalse, add a one time event listener (e.g., theone()method) for theenabledpref changing to true, and callinit()when that happens. This way we can wait until they opt-in to having these linters turned on before we do the step of loading everything over the network.
Does this make sense? When you're done doing all this, you should be able to test both ways of loading things by setting your default value for enabled above to true or false and then watching your dev tools Network tab to see what does and doesn't load in each case.
| */ | ||
| function setDocument(evt, currentEditor, previousEditor) { | ||
| if(!preferences.get("enabled")){ | ||
| return ; |
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.
Why the extra space between the n and the ;? Remove it.
|
@sgupta7857 it's been a week, what's up with this? |
|
@humphd I am having trouble loading the plugin. Can you tell why is it happening? |
| init(); | ||
| } else{ | ||
| preferences.on("change", function handleChange(){ | ||
| if(preferences.get("enabled"){ |
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.
Missing a ) at the end.
|
|
||
| function loadPreferences(){ | ||
| preferences.definePreference("enabled", "boolean", defaultPreferences.enabled); | ||
| preferences.definePreference("javascript", "array", defaultPreferences.javascript); |
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 did some debugging, and it's crashing when it tries to redefine this preference when the eslint provider is loaded. Remove this line (31) and line 32 below. In fact, just change lines 24-33 to this:
function addEnabledPref() {
// We disable this by default
preferences.definePreference("enabled", "boolean", false);
}
humphd
left a comment
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 did some debugging and was able to get things working by fixing some issues you have in your code.
Also, you must fix your indenting. It's impossible to read the code when it's all misaligned. Take some time first thing and fix all your indents to 4-spaces.
| linterManager = require("linterManager"), | ||
| pluginManager = require("pluginManager"); | ||
|
|
||
| function addEnabledPref() { |
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 line is indented too far.
| CodeInspection.register("javascript", { | ||
|
|
||
| function init(){ | ||
| CodeInspection.register("javascript", { |
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 is indented too far.
|
|
||
|
|
||
| function appReady() { | ||
| addEnabledPref() |
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.
At this point, because it's a single line function, I think you should just inline this and put preferences.definePreference("enabled", "boolean", true); here vs. calling the function.
| addEnabledPref() | ||
| if (preferences.get("enabled")) { | ||
| init(); | ||
| } |
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.
} else {
humphd
left a comment
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 want you to fix the indenting in this file, and then figure out, once and for all, why you're getting it wrong all the time. Is it because you don't know how to do it correctly? If so, it's important that you learn to do it. Is it that you are going fast and didn't notice? If so, you need to slow down. Is it that you don't care? If so, I'd encourage you to rethink about the importance of code readability, since you're making mistakes due to your misalignment, and not being able to read the code for what it is.
If you need help understanding any of this, let me know. But let's not continue to have you get it wrong.
|
|
||
| function init(){ | ||
| CodeInspection.register("javascript", { | ||
| CodeInspection.register("javascript", { |
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 entire function is indented incorrectly. I want you to actually pause for a minute, and look at what's here. There should be 4-spaces for each indent level. Look at what you have:
function init(){
CodeInspection.register("javascript", {
name: "interactive-linter-remove-jslint",
scanFile: $.noop
});
// Load up plugins and wait til they are done loading before we
// register any handlers into Brackets
pluginManager().done(function(plugins) {
for (var iPlugin in plugins) {
linterManager.registerLinter(plugins[iPlugin]);
}
EditorManager.on("activeEditorChange.interactive-linter", setDocument);
setDocument(null, EditorManager.getActiveEditor());
// If the linters change, then make sure to rebind the document with the new linter
var lastLinters;
preferences.on("change", function() {
var editor = EditorManager.getActiveEditor();
if (!editor) {
return;
}
var language = editor.document.getLanguage().getId();
var linters = preferences.get(language);
if (linters && !_.isEqual(linters, lastLinters)) {
lastLinters = linters.slice(0);
handleDocumentChange();
}
});
});
}Just casually looking at that, you can see that it makes no sense. It looks like you're closing the init() function on the 4th line. The actual close is way down at the bottom, but it's impossible to see, because you haven't indented the pluginManager's done callback properly.
We've discussed this a bunch in my office, and I don't understand why we're still discussing it. Please fix all indentation issues in this PR, push it, and then come to Github and look at it to make sure it's right and that your editor isn't lying to you.
Here's what it should look like:
function init() {
CodeInspection.register("javascript", {
name: "interactive-linter-remove-jslint",
scanFile: $.noop
});
// Load up plugins and wait til they are done loading before we
// register any handlers into Brackets
pluginManager().done(function(plugins) {
for (var iPlugin in plugins) {
linterManager.registerLinter(plugins[iPlugin]);
}
EditorManager.on("activeEditorChange.interactive-linter", setDocument);
setDocument(null, EditorManager.getActiveEditor());
// If the linters change, then make sure to rebind the document with the new linter
var lastLinters;
preferences.on("change", function() {
var editor = EditorManager.getActiveEditor();
if (!editor) {
return;
}
var language = editor.document.getLanguage().getId();
var linters = preferences.get(language);
if (linters && !_.isEqual(linters, lastLinters)) {
lastLinters = linters.slice(0);
handleDocumentChange();
}
});
});
}| } | ||
|
|
||
| require("lintIndicator"); | ||
| require("lintIndicator"); |
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.
Look at this. Surely you can see that it's not aligned with what's before/after it? Why is your indentation so wrong everywhere? Is your editor setup incorrectly?
| init(); | ||
| } | ||
| }); | ||
| }); |
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 be aligned with the preferences keyword on 197 above.
humphd
left a comment
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.
Still not right. I've tried to show you the problems visually. I get the feeling that you actually don't understand how to do this properly, which is an issue you will want to tackle, in general.
I'd recommend you install something like prettier in your editor to help you auto fix your code as you work: https://github.com/prettier/prettier.
I'd also suggest you put some serious time into figuring out when and how to indent manually. You need to know how to do this as a professional developer.
| handleDocumentChange(); | ||
| } | ||
| } | ||
| } |
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.
| if (!editor) { | ||
| return; | ||
| } | ||
| function init() { |
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.
| }); | ||
|
|
||
| }); | ||
| } |
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.
|
for some reason, the code whatever indendation I fix on sublime doesn't match on github. I am using a different editor now Atom. Will fix the indentation and upload it |
4aafaad to
5eb1061
Compare
|
I used the preetier extension. hopefully it solves the indentation problem |
|
Unfortunately this won't work. You've applied prettier's default styling (2-space indent) to the entire file, which you aren't changing here. The effect is that it's now impossible to see your actual changes, because it looks like every line has been changed. If you want to undo this commit, you can do this: Then you can fix your indenting as I asked, and push again. |
5eb1061 to
6776486
Compare
319c52c to
fbc35d4
Compare
Fix mozilla/thimble.mozilla.org#2506 * Added all components for Border Radius Inline editor * remove text selection after closing inline border radius editor * made allCornerSlider and individual slider work seperately without effecting each other * added the slider value indicator * modified BorderRadiusEditor to allow keeping all units(%,em,px) * modified BorderRadiusEditor to allow keeping all units(%,em,px)--#2 * added radio buttons to toggle slider unit * making individual corner values sync with allcorner mode value * Border UI updates * fixed when close inlineEditor the cursor do not go to top * Light theme + CSS cleanup * code cleaned up * fixed indentation and replaceAll() local function * fixed some indentations * removed _values local property from borderRadiusEditor.js * Fixed few indentations and comments * added comment for borderRadiusUtil * added more comments in borderRadiusUtils.js * Fixed few comments * Review fixes * Fixed some codes according to comments from gide * fixed indentation * fixed indentation 2x



@humphd I have made some progress on this bug. After our conversation in class, I was able to add the code that kills the dependancy for .brackets.json file by having default preferences defined with in main.js [of extension]
and lint is disable now by default
Now further I will be implementing onchange/onclick functions that will allow me to interact with toggle button in thimble.