# prefer-https πŸ“ Prefer HTTPS over HTTP. πŸ’ΌπŸš« This rule is enabled in the following [configs](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config): βœ… `recommended`, 🎨 `recommended-css`, 🌐 `recommended-html`, 🧩 `recommended-json`, πŸ“š `recommended-markdown`, πŸ’Ž `recommended-soml`, πŸ› οΈ `recommended-toml`, πŸ“‹ `recommended-yaml`. This rule is _disabled_ in the β˜‘οΈ `unopinionated` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). πŸ”§ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix). Using HTTPS avoids sending URLs to public resources over an insecure protocol. This rule checks source text, including strings, template literals, JSX, comments, and non-JavaScript files when they are linted with ESLint language plugins such as [`@eslint/css`](https://github.com/eslint/css), [`@eslint/json`](https://github.com/eslint/json), [`@eslint/markdown`](https://github.com/eslint/markdown), and [`html-eslint`](https://html-eslint.org). URLs without a public-looking top-level domain are ignored. For example, `http://localhost`, `http://example`, and `http://127.0.0.1` are allowed. Reserved non-public top-level domains are ignored too: `.example`, `.internal`, `.invalid`, `.local`, `.localdomain`, `.localhost`, `.onion`, and `.test`. Some well-known XML identifiers and the JSON Schema meta-schema identifiers (like `http://json-schema.org/draft-07/schema#`) are also ignored because rewriting them to `https:` would change their meaning. ## Options ### ignore Type: `Array`\ Default: `[]` Specify URLs or regular expressions to ignore. Strings must start with `http://` and match the complete recognized URL exactly. Regular expressions match the same text, so use `^` and `$` for a full match. They are tested from `lastIndex = 0`, without carrying state between URLs. ```js 'unicorn/prefer-https': [ 'error', { ignore: [ 'http://example.com/identifier/value', /^http:\/\/schemas\.example\.com\//v, ], }, ] ``` ## Examples ```js // ❌ const url = 'http://sindresorhus.com'; // βœ… const url = 'https://sindresorhus.com'; ``` ```js // ❌ // See http://sindresorhus.com // βœ… // See https://sindresorhus.com ``` ```jsx // ❌ const element = http://sindresorhus.com; // βœ… const element = https://sindresorhus.com; ```