-
Notifications
You must be signed in to change notification settings - Fork 394
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
lint: wrap js strings (in src/) #548
Comments
This comment has been minimized.
This comment has been minimized.
I'm unable to do this in the Prettier playground. (Wrap at 40 chars in the linked example) |
@jorgeorpinel @shcheklein they haven't addressed this issue yet. prettier/prettier#4123 I think we need to manually wrap strings. 😕 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
If you have time now to research this one @algomaster99 (or anyone out there) it would be nice, that way we can confirm or remove the issue. Keep in mind we're also using ESlint. This rule can probably address the concern: https://eslint.org/docs/rules/max-len |
@jorgeorpinel ESLint cannot fix this but it can do detect when the line goes above 80 characters. We just need to put |
Well, let's make the issue to fix all the problems it currently reports, at least, and add the ESLint rule anyway for the future. Problems: $ eslint src
yarn run v1.19.1
$ /.../dvc.org/node_modules/.bin/eslint src
/.../dvc.org/src/Diagram/index.js
209:1 error This line has a length of 83. Maximum allowed is 80 max-len
✔️ /.../dvc.org/src/Documentation/HeadInjector.js
10:1 error This line has a length of 101. Maximum allowed is 80 max-len
14:1 error This line has a length of 87. Maximum allowed is 80 max-len
18:1 error This line has a length of 95. Maximum allowed is 80 max-len
22:1 error This line has a length of 85. Maximum allowed is 80 max-len
✔️ /.../dvc.org/src/Documentation/Markdown/Markdown.js
58:1 error This line has a length of 349. Maximum allowed is 80 max-len
✔️ /.../dvc.org/src/Documentation/SidebarMenu/helper.test.js
260:1 error This line has a length of 82. Maximum allowed is 80 max-len
✔️ /.../dvc.org/src/Documentation/glossary.js
37:1 error This line has a length of 83. Maximum allowed is 80 max-len
46:1 error This line has a length of 81. Maximum allowed is 80 max-len
71:1 error This line has a length of 81. Maximum allowed is 80 max-len
✔️ /.../dvc.org/src/DownloadButton/index.js
19:1 error This line has a length of 91. Maximum allowed is 80 max-len
23:1 error This line has a length of 91. Maximum allowed is 80 max-len
27:1 error This line has a length of 97. Maximum allowed is 80 max-len
31:1 error This line has a length of 100. Maximum allowed is 80 max-len
/.../dvc.org/src/LandingHero/index.js
145:1 error This line has a length of 83. Maximum allowed is 80 max-len
159:1 error This line has a length of 83. Maximum allowed is 80 max-len
270:1 error This line has a length of 83. Maximum allowed is 80 max-len
294:1 error This line has a length of 83. Maximum allowed is 80 max-len
/.../dvc.org/src/Subscribe/index.js
32:1 error This line has a length of 83. Maximum allowed is 80 max-len
48:1 error This line has a length of 83. Maximum allowed is 80 max-len
✔️ /.../dvc.org/src/SubscribeForm/index.js
8:1 error This line has a length of 112. Maximum allowed is 80 max-len
25:1 error This line has a length of 116. Maximum allowed is 80 max-len
✔️ /.../dvc.org/src/Video/index.js
78:1 error This line has a length of 102. Maximum allowed is 80 max-len
/.../dvc.org/src/styles.js
78:1 error This line has a length of 83. Maximum allowed is 80 max-len
✖ 24 problems (24 errors, 0 warnings) UPDATE: I checked with ✔️ the ones fixed so far in #715 up to my last revision. |
@jorgeorpinel yeah, we have to do it manually first. Once it is fixed, eslint would make sure this error is not there. |
@algomaster99 I think the PR that was merge broke the style of the dvc.org for a few hours: we don't have a QA team and we trust that engineers do some basic testing. Please, review it again and run it locally every time before we merge or specify [WIP]. I've reverted the changes. Please create a new PR to handle this. @jorgeorpinel thanks for noticing this! |
@shcheklein This happened because of writing URLs in <script
type="text/javascript"
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/docsearch.min.js"
/> into this: <script
type="text/javascript"
src={`
https://cdn.jsdelivr.net/npm/
[email protected]/dist/cdn/docsearch.min.js
`}
/> The solution could be to:
<script
type="text/javascript"
src={`https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/docsearch.min.js`}
/>
<script
type="text/javascript"
// eslint-disable-next-line max-len
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/docsearch.min.js"
/> |
@algomaster99 using some special syntax for every URL looks unacceptable to me. Could you please google some discussion how do people deal with this? The most interesting thing here is that prettier broke the code. This looks like a bug to me to be honest. |
@shcheklein Okay, I got it. We could again edit
|
k, looks reasonable |
This comment has been minimized.
This comment has been minimized.
@algomaster99 but they are templates, right? |
@shcheklein Sorry, my bad! Didn't notice. 🤦♂️ |
Did we ever find a full reference of what exactly
|
@algomaster99 I think it does not answer the question :) Not very helpful link - no information whatsoever. |
So there are two packages installed in our project called -
Now to include these two configurations silmuntaneously, we simply need to add one line in {
"extends": [
"plugin:prettier/recommended"
]
} |
@algomaster99 I would clarify though that special rules set is not the full set of rules that are being applied. Probably, this is the full list https://github.com/prettier/eslint-config-prettier/blob/master/index.js . May be there is some other logic around that changes the effective list. |
@shcheklein yes, |
UPDATE: See #548 (comment).
OUTDATED:
String values in JavaScript files are currently not automatically wrapped to 80 chars by the pre-commit hook that runs
pretty-quick
, like all other lines of code. If possible, have the linter do this. E.g.This would be pretty useful to make sure the
glossary.js
strings are properly wrapped, for example.The text was updated successfully, but these errors were encountered: