noDocumentCookie
此内容尚不支持你的语言。
Diagnostic Category: lint/nursery/noDocumentCookie
Since: v1.9.4
Sources:
- Same as:
unicorn/no-document-cookie
Disallow direct assignments to document.cookie
.
It’s not recommended to use document.cookie directly as it’s easy to get the string wrong. Instead, you should use the Cookie Store API.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:1 lint/nursery/noDocumentCookie ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Direct assigning to document.cookie is not recommended.
> 1 │ document.cookie = “foo=bar”;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Consider using the Cookie Store API.
code-block.js:1:1 lint/nursery/noDocumentCookie ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Direct assigning to document.cookie is not recommended.
> 1 │ document.cookie += ”; foo=bar”;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ Consider using the Cookie Store API.