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 LF #1602

Merged
merged 1 commit into from
Dec 28, 2020
Merged

Enforce LF #1602

merged 1 commit into from
Dec 28, 2020

Conversation

XhmikosR
Copy link
Contributor

On Windows autocrlf is true which results in CRLF being using thus prettier was complaining. This should always use LF regardless of OS or git settings and should work on git >= 2.10.

Refs #1599 (comment)

@5saviahv
Copy link
Contributor

5saviahv commented Dec 26, 2020

Isn't prettier endOfLine already enforced. Its default value is lf

OK, if someone is configured GIT property core.autocrlf to true, it will convert file line endings in their working directory to CRLF, but files what were with LF line ending in repository will pushed that way. New files they introduce to repo will keep their CRLF when pushed.

autocrlf

@XhmikosR
Copy link
Contributor Author

XhmikosR commented Dec 26, 2020 via email

@XhmikosR
Copy link
Contributor Author

@fb55 this is how it is on Windows 10 with the default git settings:


C:\Users\xmr\Desktop\cheerio>ver

Microsoft Windows [Version 10.0.19042.685]

C:\Users\xmr\Desktop\cheerio>npm t

> [email protected] test C:\Users\xmr\Desktop\cheerio
> npm run lint && npm run test:mocha && npm run test:types


> [email protected] lint C:\Users\xmr\Desktop\cheerio
> npm run lint:es && npm run lint:prettier


> [email protected] lint:es C:\Users\xmr\Desktop\cheerio
> eslint --ignore-path .prettierignore .


> [email protected] lint:prettier C:\Users\xmr\Desktop\cheerio
> npm run format:prettier:raw -- --check


> [email protected] format:prettier:raw C:\Users\xmr\Desktop\cheerio
> prettier "**/*.{js,ts,md,json,yml}" --ignore-path .prettierignore "--check"

Checking formatting...
[warn] .github\dependabot.yml
[warn] .github\workflows\benchmark.yml
[warn] .github\workflows\ci.yml
[warn] .github\workflows\codeql.yml
[warn] .github\workflows\lint.yml
[warn] .github\workflows\site.yml
[warn] benchmark\benchmark.js
[warn] benchmark\suite.js
[warn] CONTRIBUTING.md
[warn] History.md
[warn] lib\api\attributes.js
[warn] lib\api\css.js
[warn] lib\api\forms.js
[warn] lib\api\manipulation.js
[warn] lib\api\traversing.js
[warn] lib\parsers\parse5.js
[warn] lib\static.js
[warn] lib\utils.js
[warn] package-lock.json
[warn] package.json
[warn] Readme.md
[warn] test\api\attributes.js
[warn] test\api\deprecated.js
[warn] test\api\manipulation.js
[warn] test\api\traversing.js
[warn] test\api\utils.js
[warn] test\cheerio.js
[warn] types\index.d.ts
[warn] Code style issues found in the above file(s). Forgot to run Prettier?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] format:prettier:raw: `prettier "**/*.{js,ts,md,json,yml}" --ignore-path .prettierignore "--check"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] format:prettier:raw script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xmr\AppData\Roaming\npm-cache\_logs\2020-12-27T14_18_03_940Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint:prettier: `npm run format:prettier:raw -- --check`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint:prettier script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xmr\AppData\Roaming\npm-cache\_logs\2020-12-27T14_18_03_970Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint: `npm run lint:es && npm run lint:prettier`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xmr\AppData\Roaming\npm-cache\_logs\2020-12-27T14_18_04_003Z-debug.log
npm ERR! Test failed.  See above for more details.

This patch enforces LF which gets rids of this issue. Alternatively, I guess you could change prettier's settings.

@5saviahv
Copy link
Contributor

Actually same happens with linux until you run npm run format:prettier after that those errors go away.

@XhmikosR
Copy link
Contributor Author

XhmikosR commented Dec 27, 2020 via email

@fb55 fb55 merged commit 0bbad23 into cheeriojs:main Dec 28, 2020
@XhmikosR XhmikosR deleted the lf branch December 28, 2020 07:17
@fb55
Copy link
Member

fb55 commented Dec 28, 2020

Thanks @XhmikosR! This seems easy enough of a change to help Windows users.

Thanks @5saviahv for raising the Prettier issue, that's the question I would have had as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants