-
Notifications
You must be signed in to change notification settings - Fork 401
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
Add SLDS Linter #101
Add SLDS Linter #101
Conversation
@@ -1,5 +1,5 @@ | |||
# salesforcedx-vscode-lightning |
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.
@ruthemmanuelle - Could you review this README for @ayeshakmaz and @engai?
@engai @ayeshakmaz Could you take a look at your test to see why it's failing on windows? Could it be you are looking for a particular path and that you are using |
@vazexqi Yes. It's trying to open |
Try using https://nodejs.org/api/path.html#path_path_joint paths. You might want to also check to see that you are not using / in your code and not just the tests. |
Codecov Report
@@ Coverage Diff @@
## develop #101 +/- ##
===========================================
- Coverage 82.66% 82.58% -0.08%
===========================================
Files 66 67 +1
Lines 1817 1832 +15
Branches 228 229 +1
===========================================
+ Hits 1502 1513 +11
- Misses 279 283 +4
Partials 36 36
Continue to review full report at Codecov.
|
Paths look correct at the moment (some are |
@engai - Could you get a Windows VM and run the tests locally or add more logging for when the test fails? The error is
|
@vazexqi the test is essentially looking for our command within the workspace command list. This will only be there when the extension runs. Not sure what else to log in this case. The extension functions and tests pass when ran in VSCode on our VM, but the extension doesn't seem to run when ran from the test script. The correct workspace is opened, but no syntax highlighting or linting appears. |
|
||
it('Should create deprecatedClassName command', async () => { | ||
const commandList = await vscode.commands.getCommands(true); | ||
expect(commandList).to.include('deprecatedClassName'); |
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.
@engai I guess you can log here to see what is the list of commandList on the autobuild and how that differs from the one you have locally. I am not yet sure why the test will fail since this seems to be a simple test.
@engai That is helpful. So we can at least narrow it down to the command not loading. How are you running the tests locally? How does it differ from the appveyor.yml and travis.yml files? Could you be running it from a different directory? On that note, I just noticed that your command doesn't follow the convention. Could you rename your command to |
@vazexqi To run via test script (Does not pass) - Following these steps in the
Running in VSCode (Passes):
On a side note, currently unable to run tests via the script (was working yesterday). Seems like the script can't find a VSCode executable: Have you run into this problem? Looks similar to microsoft/vscode-extension-vscode#30 As for the command name, thanks for the heads up. I'll go ahead and change that. |
I just ran the tests locally and I'm able to produce the issue (on my Mac). I suspect that it's not loading something when run from the top-level.
|
await vscode.workspace.openTextDocument(res[0]).then( | ||
document => vscode.window.showTextDocument(document) | ||
res = await vscode.workspace.findFiles( | ||
path.join('**', 'DemoComponent.cmp') |
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 should be precise and look exactly for the .cmp you know has the deprecatedclassnames.
@engai - Take a look at my latest commit where I moved your tests to the salesforcedx-vscode-lightning package. The tests need to be there since it depends on an actual activation event. It runs when you do it from VS Code itself since you are loading all the packages (see .vscode/launch.json). But, when you run the tests from the command line, the tests only load the extensions for that package. |
Ah that makes sense. The tests aren't passing within VSCode, but i'll work on that within the lightning tests |
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, don't forget to change the command name to something more descriptive.
.vscode/launch.json
Outdated
"preLaunchTask": "Compile" | ||
}, | ||
{ | ||
"name": "Launch Salesforce DX VS Code SLDS Linter Tests", |
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.
@engai - This one probably needs to be updated since I removed the ${workspaceRoot}/packages/salesforcedx-slds-linter/assets/sfdx-simple
res = await vscode.workspace.findFiles( | ||
path.join('**', 'DemoComponent.cmp') | ||
); | ||
await vscode.workspace |
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.
@engai Since you open the file, you should probably have an after that closes it too (just to be tidy). So far it's not causing problems but as we have more tests in the future, I think it's good for each test to clean up after itself.
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.
Added an after to close the editor. Looks like closeFile is deprecated.
@vazexqi Wasn't sure if it would affect the end-to-end tests, i'll remove mine and add the .cmp file to system-test. Though .DS_Store was in the .git_ignore, i'll remove those as well. |
In one of my previous commits I already added the DemoComponent to the system-tests/assets folder. You should be able to see it. |
@vazexqi I'm looking in system-tests/assets, but not seeing that moved DemoComponent |
@ayeshakmaz - Crap. I must have forgotten to commit it. One moment. |
@ayeshakmaz and @engai - I've added the DemoComponent.cmp now. |
* | ||
* If ommitted, we will assume _message. | ||
*/ | ||
export const messages = { |
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.
@ruthemmanuelle - Could you take a look at these messages? There is a screenshot that shows where there are used in this PR.
@Sweetman - Here's another case where the travis builds just hangs. |
@vazexqi I've added 3 tests to our slds-linter package. Let us know if there is anything else we should add. Appveyor build looks good as well. |
it('Should send correct string', () => { | ||
|
||
validateTextDocument('\n class"slds-button--brand" \n', 'uri', connection); | ||
if (args) { |
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.
@engai I think you should also assert that args
is not null in the tests.
Because if it turns out that args
is null, then if will skip the if(args) {...} and then the test will pass, right?
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.
Right. Pushed a fix to assert when null
* Code actions available on click | ||
* Linter won't run if SLDS is included as a static resource in your project | ||
* Code actions are available on click | ||
Note: The linter won't run if SLDS is included as a static resource in your project. | ||
|
||
![SLDS Linter detecting deprecated '--' class name syntax](https://raw.githubusercontent.com/forcedotcom/salesforcedx-vscode/ayesha/add-slds-linter/packages/salesforcedx-vscode-lightning/images/lightning_slds.png) |
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.
We should take a new screenshot that includes the updated messages. We'll also need to update this path to use /develop/ instead of /ayesha/add-slds-linter/, but if we do that before merging in this PR the image won't display. It would be good if the resolution and text size of the screenshot approximately matched the other screenshots in this README.
fix_all: | ||
'Fix all auto-fixable problems', | ||
fix_error: | ||
'Failed to apply SLDS Validator fixes to the document', | ||
'Failed to apply SLDS Validator fixes to the document.', |
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.
Do we have any idea what would have caused this problem? Can we suggest a solution? Also, I added a period, but if this error displays in the same format as the other messages in this section we can remove the period. VS Code seems to use sentence-case capitalization and no end punctuation for these contextual messages.
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.
It will only fail if the edit function doesn't successfully run. This wouldn't be a problem that the end user can fix. One thing we can suggest is filing an issue on Github with us.
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.
It doesn't display along with the other messages, so the period should be okay
break; | ||
} | ||
default: { | ||
codeMessage = 'same problems'; |
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.
Is there a reason this one is not done using nls.localize
?
vscode.workspace.findFiles('**/staticresources/*.resource').then( | ||
// all good | ||
(result: vscode.Uri[]) => { | ||
for (let i = 0; i < result.length; i++) { |
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.
Cosmetic: Is there a reason we use for(let i = 0...)
instead of the for(const a of blah)?
// Options to control the language client | ||
const clientOptions: LanguageClientOptions = { | ||
// Register the server for plain text documents | ||
documentSelector: ['plaintext', 'html'], |
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.
@ayeshakmaz - I think we only want HTML, right? No need for it to scan plaintext?
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.
Yeah, we can take out the plain text option
You need to have it in an actual vscode extension to be able to access the vscode namespace.
@W-4267770@
Merging this in! Thanks @engai and @ayeshakmaz |
What does this PR do?
Adds SLDS Linter feature to Lightning Package
What issues does this PR fix or reference?
@W-4267770@