-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add new JS linter rules #17699
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 new JS linter rules #17699
Conversation
Adds a few useful rules from eslint-plugin-github. Notable changes: - Forbid dataset usage, its camel-casing behaviour makes it hard to grep for attributes. - Forbid .then() and .catch(), we should generally prefer await for new code. For rare cases where they are useful, a eslint-disable-line directive can be set. - Add docs js to linting
About "Forbid dataset usage", what's the recommended way to bind a variable to a DOM node? For example, in the legacy code, we bind a SimpleMDE object to the textarea DOM node's dataset. |
I would recommend against such techiques but I think either jQuery's |
I think we had better make an agreement and write it into the guideline.
|
Sorry, but this seems overkill to me. Any other cases should aim to not attach non-string data directly to DOM elements to re-use later, this is a big anti-pattern. Stuff like that is not even possible with React/Vue for example, the canonical way is to use state variables because those outlive the lifetime of DOM nodes. |
So the conclusion can be:
Right? |
Yes, sounds right. I would also consider removing/refactoring the existing |
Would you like to write the conclusion into the frontend guideline in this PR, or would we update the guideline in other PRs? |
I think we can handle it during review and/or via linter. I guess it shouldn't actually be hard to create a custom eslint rule that forbids |
Some conflicts with main branch |
conflicts resolved. |
make L-G-T-M work |
* the project board was broken, this PR fixes it, and refactor the code, and we prevent the uncategorized column from being dragged. * improve the frontend guideline (as discussed in go-gitea#17699)
* the project board was broken, this PR fixes it, and refactor the code, and we prevent the uncategorized column from being dragged. * improve the frontend guideline (as discussed in #17699)
* Add new JS linter rules Adds a few useful rules from eslint-plugin-github. Notable changes: - Forbid dataset usage, its camel-casing behaviour makes it hard to grep for attributes. - Forbid .then() and .catch(), we should generally prefer await for new code. For rare cases where they are useful, a eslint-disable-line directive can be set. - Add docs js to linting * also enable github/array-foreach * small tweak Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* the project board was broken, this PR fixes it, and refactor the code, and we prevent the uncategorized column from being dragged. * improve the frontend guideline (as discussed in go-gitea#17699)
Adds a few useful rules from eslint-plugin-github. Notable changes:
dataset
usage, its camel-casing behaviour makes it hard to grep for attributes..then()
and.catch()
, we should generally preferawait
for new code. For rare cases where they are useful, aeslint-disable-line
directive can be set.array#forEach
,for-of
is superior because it allows flow-control statements.