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

Rule proposal: prefer-https #971

Open
sindresorhus opened this issue Dec 30, 2020 · 9 comments
Open

Rule proposal: prefer-https #971

sindresorhus opened this issue Dec 30, 2020 · 9 comments

Comments

@sindresorhus
Copy link
Owner

Enforce using HTTPS URLs over HTTP.

Fail

const foo = 'http://sindresorhus.com';

// Hello: http://sindresorhus.com

Pass

const foo = 'https://sindresorhus.com';

// Hello: https://sindresorhus.com

Alternative name: prefer-https. Which one do people prefer?

I'm aware this could be partly solved with the string-content rule, but I don't think most people would think of this and it also wouldn't work in comments.

@sindresorhus
Copy link
Owner Author

This is now accepted. The rule name should be prefer-https.

@sindresorhus sindresorhus changed the title Rule proposal: no-http Rule proposal: prefer-https Jan 16, 2021
@himynameisdave
Copy link
Contributor

I can pick this up!

@JounQin
Copy link
Contributor

JounQin commented Jan 27, 2021

Should http://localhost for example be ignored?

@sindresorhus
Copy link
Owner Author

Should http://localhost for example be ignored?

Yes, any URL without a TLD should be ignored.

@manovotny
Copy link
Contributor

Is this still desired since string-content can accomplish this now?

@sindresorhus
Copy link
Owner Author

Yes, that's addressed in the issue description.

@manovotny
Copy link
Contributor

My apologies @sindresorhus. That's what I get for skimming too quickly. 😞

@manovotny
Copy link
Contributor

FWIW, just in case it helps here, this is the regex I came up with for use with string-content.

(?!(?=.*(localhost|0\.0\.0\.0|127\.0\.0\.1)))^http\:

Demo here on regex101: https://regex101.com/r/ITZChx/1

@sindresorhus
Copy link
Owner Author

If anyone wants to work on this, see the initial attempt and feedback in #1084.

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

Successfully merging a pull request may close this issue.

4 participants