-
Notifications
You must be signed in to change notification settings - Fork 209
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(base): introduce static version property for component class #3582
Conversation
Tachometer resultsChromeaccordion permalink
action-bar permalink
action-button permalink
action-group permalink
action-menu permalink
Firefoxaccordion permalink
action-bar permalink
action-button permalink
action-group permalink
action-menu permalink
|
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.
Some nitty things, but really close. Seems like we'd be in a good place to test this out on the next release after those small points of clean up.
tools/.eslintrc.json
Outdated
"files": ["./base/src/version.js"], | ||
"rules": { | ||
"notice/notice": "off" | ||
} |
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 was this needed?
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 the generator can't add this information, should we add this file to .eslintignore
instead?
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.
Or I guess the question is why isn't listing it there enough?
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 think the intension here is to allow the linter to run on both the files (d.ts & .js) as tools/**/*.d.ts
excludes tools/base/src/version.d.ts
file from tools in .eslintignore
Then to ignore the header error for version.js we had to add the above override rule inside .eslintrc.json.
I believe we can safely remove the last line !tools/base/src/version.js
as it's included by default. Although if we just add tools/base/src/version.js
to .eslintignore we would not require the above change in .eslintrc.json.
@rickharris why is it necessary to add version.d.ts & version.js files to 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.
Yeah I think that we can eslintignore the files if we'd like to. I also think you're right that we can remove !tools/base/src/version.js
from the eslintignore file. Either option should be fine, just a preference of if we want to ignore the whole file or just the header rule.
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.
@Westbrook added tools/base/src/version.js to .eslintignore & removed the header override.
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.
Are we able to remove the updates to this file with that change?
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.
Yes Removed it.
tools/base/test/base.test.ts
Outdated
@@ -10,6 +10,7 @@ governing permissions and limitations under the License. | |||
*/ | |||
import { SpectrumElement } from '@spectrum-web-components/base'; | |||
import { elementUpdated, expect, fixture, html } from '@open-wc/testing'; | |||
import { version } from '../src/version'; |
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.
File extension.
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.
@Westbrook After adding the file extensions I see that all tests are failing reason being the version.js is being created/updated using genversion & it's excluded from build so version.dev.js is not created & all the test's fail.
Is it okay to roll back to removing extension from version as only version.js file is being created ?
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.
File extensions are required. Checkout my other note re *.dev.js
files.
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.
CI is failing because by default our tooling expects there to be both a version.js
file AND a version.dev.js
file. The laziest answer is to give it what it wants and build both files in the pre-commit
. Alternatively, we could add specific support for version.js
in this script so that the expectation of the version.dev.js
file is not created. Both are a tiny bit awkward, so I'm fine with either.
@Westbrook Added the support in script by removing the development condition similar to .css. |
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.
Let's try it. If it does work for the team, I'd love for us to go back and document it's usage, and how other teams might override it, etc. but for now we can keep it more on the quiet side.
fb302ac
to
0071ff7
Compare
* fix(base): add static version property * chore: version update by commit * refactor: added version.js to eslintignore and updated file extensions * fix(base): fixed unit test case & removed development condition from version.js * refactor: removed notice rule override as version.js has been added to .eslintignore --------- Co-authored-by: Rick Harris <[email protected]> Co-authored-by: Ravi Sharma <[email protected]>
Description
Adding Static property for component classes which can be useful for component libraries to handle scenarios like version conflict.
Related issue(s)
Motivation and context
Adding version to SWC components would help component library to make decision in below scenarios ::
Versioning would also help in long term approach for custom scoped registries as discussed in #3556
How has this been tested?
version
is present inSpectrumElement
Screenshots (if appropriate)
Types of changes
Checklist
Best practices
This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against
main
.