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

fix: eslint-prettier error #50

Merged
merged 1 commit into from
Oct 29, 2023
Merged

fix: eslint-prettier error #50

merged 1 commit into from
Oct 29, 2023

Conversation

ComradeVanti
Copy link
Collaborator

When attempting to fix eslint rules in file, the following error appeared

Error: "prettier/vue" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21

Reading the linked changelog, it seemed the fix was to simply only use the prettier/recommended extension. Simplified eslintrc to reflect this.

When attempting to fix eslint rules in file, the following error appeared

```Error: "prettier/vue" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21```

Reading the linked changelog, it seemed the fix was to simply only use the prettier/recommended extension. Simplified eslintrc to reflect this.
@ComradeVanti
Copy link
Collaborator Author

ComradeVanti commented Oct 17, 2023

Edit: Rebased so the latest upstream changes are included

@favoyang favoyang merged commit 14f8ba5 into openupm:master Oct 29, 2023
2 checks passed
favoyang added a commit that referenced this pull request Nov 1, 2023
* fix: eslint-prettier error

When attempting to fix eslint rules in file, the following error appeared

```Error: "prettier/vue" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21```

Reading the linked changelog, it seemed the fix was to simply only use the prettier/recommended extension. Simplified eslintrc to reflect this.

* deps: install typescript

* misc: ignore builds

* feat: convert to typescript

* fix: eslint-prettier error

When attempting to fix eslint rules in file, the following error appeared

```Error: "prettier/vue" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21```

Reading the linked changelog, it seemed the fix was to simply only use the prettier/recommended extension. Simplified eslintrc to reflect this.

* fix: eslint errors in typescript-files

Eslint was complaining about various keywords being reserved and was unerlining them. Fixed by installing `typescript-eslint` according to [this guide](https://typescript-eslint.io/getting-started)

* misc: apply eslint rules

reformat and clean-up using new eslint config

* chore(deps): bump mkdirp

Bumped because >=2 includes typings and seemingly no other breaking changes

* chore: fix eslint end-of-line error

On my Windows machine eslint was constantly complaining about line endings. Fixed using this answer https://stackoverflow.com/a/53769213

* feat: ambient typings for js module

Add ambient typings for another-npm-registry-client

* refactor: move file

Move types file into types folder

* refactor: add basic type for NpmClient

Based on usage. Could use some cleanup

* refactor: declare global types

Declare types instead of exporting them for easier use

* refactor: improve ambient type declarations

Improve type declarations for another-npm-registry-client by reading it's docs

* conf: bump target es version

Bump to ES2020 to match Node 14 after consulting https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping

* deps: downgrade node types

Downgrade to match node version

* refactor: add correct response type

* feat: typecheck errors

Add some custom type assertions for expected errors

* misc: add shared idea files

* refactor: clean up imports

* refactor: make variables constant

Make variables constant where possible

* misc: remove outdated ts-ignores

* refactor: handle potential null

* fix: add better type for upm auth

Previously mistakenly used the same auth type as for npm

* refactor: fix type warning

Instead of assigning different auth properties separately, assign all at once in the different if branches in order to avoid type warnings

* fix: type parameter

* misc: delete outdates jsdoc comment

* fix: unhandled null values

Check token and _auth for null before respective usage

* fix: type error

Convert results array to string before logging to avoid type error. I joined the results using line-breaks, don't know if this is intended.

* refactor: use existing type

Previously added a custom type for npm search options even though such a type already exists

* fix: add missing import

Response type was ambiguous without import

* fix: remove extraneous declare

It seems to cause problems and to be honest I don't know if we need it

* fix: type error

The result of the nmp-search function is search.Result but because we know the openupm server actually returns PkgInfo objects we can change the type

* fix: remove extraneous ts-ignore

* fix: type error

Instead of initializing env with empty object, populate with default members in order to avoid type error

* fix: type error

Type was declared incorrectly

* misc: remove extraneous ts-ignores

* fix: type error

Based on line 166 we can assume that undefined is actually a valid value for the version. Adjusted signature accordingly

* refactor: prevent value conversion

Explicitly check for undefined instead using auto-conversion to avoid "isGitOrLocal" becoming equal to some string

* misc: handle undefined

Probably unrecoverable, so we just throw

* refactor: shorten and fix type error

Use Object.assign instead of copying all properties manually. This also avoids an error for unchecked property access

* fix: type error

Make properties of options optional

* fix: potential undefined error

* fix: extraneous parameter

According to the signature of search it expects only one parameter. Removed the second empty string parameter

* fix: editing readonly list

The array given to findIndex seems to be readonly so instead we modify the original lines array

* fix: type errors

First we type-assert the result of npmFetch.json to match its usage. We can assume that it is either an array or record of packages.
We also move the log until later in the code and log the objects variable instead of results, since that is guarantied to be an array. We also convert the array to a string using join for better logging

* refactor: simplify property access

* fix: handle undefined

Throw if no latest version could be found

* fix: handle undefined

Throw if upm-config dir-path could not be resolved

* fix: handle null

Throw if editor-version could not be parsed

* fix: type errors

Add type for editor-version regex matches in order to prevent type errors. Also on line 501 I removed the toLowerCase() because it does not seem to be necessary looking at the regex

* fix: getLatestVersion should return undefined

By reading the tests I saw that this function should return undefined if the version could not be determined. Changed signature

* refactor: remove outdated logic

See #52 (comment)

* fix: handle undefined

Throw if version of package to add could not be determined

* fix: fix type error

Allow undefined as possible value for version in table-row

* refactor: assert undefined

Version is required in order to print package info

* refactor: remove unused imports

* fix: unhandled undefined

Latest version is required

* fix: handle undefined

Require latest version

* refactor: simplify ifs

Remove unnecessary boolean comparisons

* refactor: inline return

* fix: incorrectly registering errors

The callbacks used by the registry client incorrectly always registered an error. Added a null-check to only create an error when something actually went wrong

* misc: add build npm script

Just runs tsc

* misc: reformat file

* fix: undefined error

Some tests where failing because there was a throw if a package with unknown version was added. Undefined was an acceptable value, so the throw was removed and the types changed accordingly

* conf: generate sourcemaps

To enable debugging

* Revert "refactor: simplify ifs"

This reverts commit f9ae663.

* fix: incorrect type for env properties

* fix: invalid type assertion

* refactor: change type

Expand type for package names with attached version to allow all strings for the version. The reason is that the string after the @ may not only include versions such as "1.0.0" but also tags such as "beta"

* refactor: rename type

Rename PkgVersion to PkgVersionInfo in order to be more in line with PkgInfo type name

* refactor: rename type

Extend type name to be clearer

* refactor: simplify package name type

A package-name can now include a version or not

* refactor: make property optional

As indicated by usage

* refactor: extract utility function

Extract function that checks if the version-name of a package is a url version, such as a git-url. For now we do this as before by just checking if it starts with one of the common protocols

* refactor: rename type

Shorten version-name type name to just version, since it no longer conflicts with version-info

* refactor: remove extraneous if

IDE tells me that this if is always false

* refactor: rename module

To match type

* refactor: extract and rename function

Rename the parseName function to splitPackageName to better reflect it's purpose. Also moved to separate module

* misc: convert tests to typescript

Whole bunch of TS errors still, but the tests all pass

* refactor: optimize test imports

* refactor: convert type declarations to exports

Seems to cause less TS problems that way

* refactor: make properties optional

According to usage in tests, these properties should be optional

* fix: type errors in test utils

Add return and param types for all functions

* misc: reformat files

* refactor: make properties optional

According to usage in tests

* fix: inspector type errors in tests

Type inspect variables. We force the null because it is guaranteed that inspectors will be set before a test is run

* refactor: remove unused constants

* refactor: remove unnecessary await

a

* refactor: make properties optional

According to usage in tests

* refactor: fix null and undefined warnings in test

Assert not-null or not-undefined where applicable

* misc: drop outdated test

* feat: fix type error

Allow partial pkg-infos in order to satisfy test setups

* fix: null error

Allow null as seen in tests

* conf: simplify test script

ts-mocha already compiles TS

* misc: change bin structure

Instead of building the package using tsc and then running the js file, we can run using ts-node. That way we only need ts files in the project. For this to work a few changes needed to be done:
- Removed the initial empty index file
- Moved bin-files into lib
- Converted bin files to ts and renamed them to index/index-cn
- Changed the shebang in the index files to use ts-node. This also requires ts-node is a dependency of the package
- Adjust tsconfig in order to work with ts-node

Seems like the package still works as intended. It might take a little bit longer to run because of the additional compile step

* misc: add missing typescript dependency

Seems like mocha requires it

* chore: fix eslint-prettier error (#50)

When attempting to fix eslint rules in file, the following error appeared

```Error: "prettier/vue" has been merged into "prettier" in eslint-config-prettier 8.0.0. See: https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21```

Reading the linked changelog, it seemed the fix was to simply only use the prettier/recommended extension. Simplified eslintrc to reflect this.

* deps: install typescript

* misc: ignore builds

* feat: convert to typescript

* fix: eslint errors in typescript-files

Eslint was complaining about various keywords being reserved and was unerlining them. Fixed by installing `typescript-eslint` according to [this guide](https://typescript-eslint.io/getting-started)

* misc: apply eslint rules

reformat and clean-up using new eslint config

* chore(deps): bump mkdirp

Bumped because >=2 includes typings and seemingly no other breaking changes

* chore: fix eslint end-of-line error

On my Windows machine eslint was constantly complaining about line endings. Fixed using this answer https://stackoverflow.com/a/53769213

* feat: ambient typings for js module

Add ambient typings for another-npm-registry-client

* refactor: move file

Move types file into types folder

* refactor: add basic type for NpmClient

Based on usage. Could use some cleanup

* refactor: declare global types

Declare types instead of exporting them for easier use

* refactor: improve ambient type declarations

Improve type declarations for another-npm-registry-client by reading it's docs

* conf: bump target es version

Bump to ES2020 to match Node 14 after consulting https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping

* deps: downgrade node types

Downgrade to match node version

* refactor: add correct response type

* feat: typecheck errors

Add some custom type assertions for expected errors

* misc: add shared idea files

* refactor: clean up imports

* refactor: make variables constant

Make variables constant where possible

* misc: remove outdated ts-ignores

* refactor: handle potential null

* fix: add better type for upm auth

Previously mistakenly used the same auth type as for npm

* refactor: fix type warning

Instead of assigning different auth properties separately, assign all at once in the different if branches in order to avoid type warnings

* fix: type parameter

* misc: delete outdates jsdoc comment

* fix: unhandled null values

Check token and _auth for null before respective usage

* fix: type error

Convert results array to string before logging to avoid type error. I joined the results using line-breaks, don't know if this is intended.

* refactor: use existing type

Previously added a custom type for npm search options even though such a type already exists

* fix: add missing import

Response type was ambiguous without import

* fix: remove extraneous declare

It seems to cause problems and to be honest I don't know if we need it

* fix: type error

The result of the nmp-search function is search.Result but because we know the openupm server actually returns PkgInfo objects we can change the type

* fix: remove extraneous ts-ignore

* fix: type error

Instead of initializing env with empty object, populate with default members in order to avoid type error

* fix: type error

Type was declared incorrectly

* misc: remove extraneous ts-ignores

* fix: type error

Based on line 166 we can assume that undefined is actually a valid value for the version. Adjusted signature accordingly

* refactor: prevent value conversion

Explicitly check for undefined instead using auto-conversion to avoid "isGitOrLocal" becoming equal to some string

* misc: handle undefined

Probably unrecoverable, so we just throw

* refactor: shorten and fix type error

Use Object.assign instead of copying all properties manually. This also avoids an error for unchecked property access

* fix: type error

Make properties of options optional

* fix: potential undefined error

* fix: extraneous parameter

According to the signature of search it expects only one parameter. Removed the second empty string parameter

* fix: editing readonly list

The array given to findIndex seems to be readonly so instead we modify the original lines array

* fix: type errors

First we type-assert the result of npmFetch.json to match its usage. We can assume that it is either an array or record of packages.
We also move the log until later in the code and log the objects variable instead of results, since that is guarantied to be an array. We also convert the array to a string using join for better logging

* refactor: simplify property access

* fix: handle undefined

Throw if no latest version could be found

* fix: handle undefined

Throw if upm-config dir-path could not be resolved

* fix: handle null

Throw if editor-version could not be parsed

* fix: type errors

Add type for editor-version regex matches in order to prevent type errors. Also on line 501 I removed the toLowerCase() because it does not seem to be necessary looking at the regex

* fix: getLatestVersion should return undefined

By reading the tests I saw that this function should return undefined if the version could not be determined. Changed signature

* refactor: remove outdated logic

See #52 (comment)

* fix: handle undefined

Throw if version of package to add could not be determined

* fix: fix type error

Allow undefined as possible value for version in table-row

* refactor: assert undefined

Version is required in order to print package info

* refactor: remove unused imports

* fix: unhandled undefined

Latest version is required

* fix: handle undefined

Require latest version

* refactor: simplify ifs

Remove unnecessary boolean comparisons

* refactor: inline return

* fix: incorrectly registering errors

The callbacks used by the registry client incorrectly always registered an error. Added a null-check to only create an error when something actually went wrong

* misc: add build npm script

Just runs tsc

* misc: reformat file

* fix: undefined error

Some tests where failing because there was a throw if a package with unknown version was added. Undefined was an acceptable value, so the throw was removed and the types changed accordingly

* conf: generate sourcemaps

To enable debugging

* Revert "refactor: simplify ifs"

This reverts commit f9ae663.

* fix: incorrect type for env properties

* fix: invalid type assertion

* refactor: change type

Expand type for package names with attached version to allow all strings for the version. The reason is that the string after the @ may not only include versions such as "1.0.0" but also tags such as "beta"

* refactor: rename type

Rename PkgVersion to PkgVersionInfo in order to be more in line with PkgInfo type name

* refactor: rename type

Extend type name to be clearer

* refactor: simplify package name type

A package-name can now include a version or not

* refactor: make property optional

As indicated by usage

* refactor: extract utility function

Extract function that checks if the version-name of a package is a url version, such as a git-url. For now we do this as before by just checking if it starts with one of the common protocols

* refactor: rename type

Shorten version-name type name to just version, since it no longer conflicts with version-info

* refactor: remove extraneous if

IDE tells me that this if is always false

* refactor: rename module

To match type

* refactor: extract and rename function

Rename the parseName function to splitPackageName to better reflect it's purpose. Also moved to separate module

* misc: convert tests to typescript

Whole bunch of TS errors still, but the tests all pass

* refactor: optimize test imports

* refactor: convert type declarations to exports

Seems to cause less TS problems that way

* refactor: make properties optional

According to usage in tests, these properties should be optional

* fix: type errors in test utils

Add return and param types for all functions

* misc: reformat files

* refactor: make properties optional

According to usage in tests

* fix: inspector type errors in tests

Type inspect variables. We force the null because it is guaranteed that inspectors will be set before a test is run

* refactor: remove unused constants

* refactor: remove unnecessary await

a

* refactor: make properties optional

According to usage in tests

* refactor: fix null and undefined warnings in test

Assert not-null or not-undefined where applicable

* misc: drop outdated test

* feat: fix type error

Allow partial pkg-infos in order to satisfy test setups

* fix: null error

Allow null as seen in tests

* conf: simplify test script

ts-mocha already compiles TS

* misc: change bin structure

Instead of building the package using tsc and then running the js file, we can run using ts-node. That way we only need ts files in the project. For this to work a few changes needed to be done:
- Removed the initial empty index file
- Moved bin-files into lib
- Converted bin files to ts and renamed them to index/index-cn
- Changed the shebang in the index files to use ts-node. This also requires ts-node is a dependency of the package
- Adjust tsconfig in order to work with ts-node

Seems like the package still works as intended. It might take a little bit longer to run because of the additional compile step

* misc: add missing typescript dependency

Seems like mocha requires it

* Bump node version

Bump from 14 to 16. See #52 (comment)

* misc: better build structure

See #52 (comment)

* misc: add CI TS build step

* misc: remove unused dependencies

* misc: regenerate package lock

* chore: update .node-version to 16

* chore: update .npmignore

* fix: add the npm clean script to run before build

---------

Co-authored-by: Favo Yang <favoyang@gmail.com>
github-actions bot pushed a commit that referenced this pull request Nov 1, 2023
# [1.16.0](1.15.5...1.16.0) (2023-11-01)

### Features

* convert project to TypeScript ([#52](#52)), require node v16 ([8e68b9a](8e68b9a)), closes [/github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21](https://github.com//github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md/issues/version-800-2021-02-21) [/github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21](https://github.com//github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md/issues/version-800-2021-02-21) [/github.com//pull/52#issuecomment-1776779428](https://github.com//github.com/openupm/openupm-cli/pull/52/issues/issuecomment-1776779428) [#50](#50) [/github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21](https://github.com//github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md/issues/version-800-2021-02-21) [/github.com//pull/52#issuecomment-1776779428](https://github.com//github.com/openupm/openupm-cli/pull/52/issues/issuecomment-1776779428) [/github.com//pull/52#discussion_r1375481622](https://github.com//github.com/openupm/openupm-cli/pull/52/issues/discussion_r1375481622) [/github.com//pull/52#discussion_r1378008074](https://github.com//github.com/openupm/openupm-cli/pull/52/issues/discussion_r1378008074)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants