Skip to content
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

Enforce Dot Notation #47

Merged
merged 7 commits into from
Dec 12, 2022

Conversation

smorrisj
Copy link
Contributor

@smorrisj smorrisj commented Dec 6, 2022

What should our stance on enforcing dot notation be? I found some spots where javascript key notation is used for getting and setting values. I'd like to propose that we take a stance of using idiomatic typescript whenever possible, including using the dot syntax.

It gets a bit trickier for any types. I'd propose that we leave the enforcement of the rule at error and manually suppress these on a case by case basis. I would think that for this issue, having a lot of manual suppressions would indicate some kind of design smell in the types that we'd want to address.

Not sure how strictly we'd like to enforce dot notation for any types
@scottdover
Copy link
Contributor

I was just writing up an issue to discuss consistency :). This is one that I was going to mention since we chatted about it.

I would think that for this issue, having a lot of manual suppressions would indicate some kind of design smell in the types that we'd want to address.

I agree. And, using the any type should be discouraged unless absolutely necessary

@smorrisj smorrisj changed the title Refactor/enforce dot notation Enforce Dot Notation Dec 6, 2022
@smorrisj
Copy link
Contributor Author

smorrisj commented Dec 6, 2022

I was just writing up an issue to discuss consistency :). This is one that I was going to mention since we chatted about it.

Great Idea. There are other things on that issue we'd want to address as well. Once its in, can link it here.

@scottdover
Copy link
Contributor

Here it is :) - #48

@scottdover scottdover linked an issue Dec 7, 2022 that may be closed by this pull request
* revert changes in lsp due to any type usage
* add eslint ignore file
* add typescript-eslint rule for dot-notation instead of the vanilla eslint variety
@smorrisj smorrisj marked this pull request as ready for review December 8, 2022 19:45
@2TomLi 2TomLi added the code quality Code quality related issues label Dec 8, 2022
@@ -0,0 +1 @@
.eslintrc.js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this added?

Copy link
Contributor Author

@smorrisj smorrisj Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the eslint extension output log, there were errors in the log about not finding an eslintignore file. The terminal execution looked fine however.

The error was:

Error: ENOENT: no such file or directory, realpath '/Users/jomorr/dev/src/opensource/vscode-sas-extension/.eslintignore'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this error on my machine. Do you have specific setting in your extension? I can't think of why this should be an error:) But it's not a big deal. Others good to me

@@ -4,6 +4,11 @@ module.exports = {
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
project: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more details here: https://eslint.org/docs/latest/user-guide/configuring/configuration-files . Had to look this up because I've never seen it before. I think the last two array entries may be redundant, since the root .tsconfig.json references the client/server specific tsconfig

Copy link
Contributor Author

@smorrisj smorrisj Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was required due to adding a rule from the typescript-estlint plugin. Without adding the project setting, the following error would be seen:

You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.

It the client and server tsconfigs are removed, there will be numerous errors to this effect:

0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: server/src/sas/SyntaxProvider.ts.
The file must be included in at least one of the projects provided

@@ -2,7 +2,7 @@
// Licensed under SAS Code Extension Terms, available at Code_Extension_Agreement.pdf

/* eslint-disable @typescript-eslint/explicit-module-boundary-types,
@typescript-eslint/no-unused-vars,@typescript-eslint/no-explicit-any */
@typescript-eslint/no-unused-vars,@typescript-eslint/no-explicit-any,@typescript-eslint/dot-notation */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scnwwu Do you know if this file was copy/pasted from somewhere else? In other words, should it be treated as "generated" code? If not, I'm wondering if there's a plan to cleanup the rules we disable here?

@scottdover
Copy link
Contributor

I'd like to get @scnwwu's feedback on this one as well, but it looks good to me

@@ -0,0 +1 @@
.eslintrc.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this error on my machine. Do you have specific setting in your extension? I can't think of why this should be an error:) But it's not a big deal. Others good to me

@smorrisj smorrisj merged commit 6780605 into sassoftware:main Dec 12, 2022
@smorrisj smorrisj deleted the refactor/enforce-dot-notation branch December 12, 2022 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Code quality related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix inconsistent code formatting
4 participants