unicorn/no-document-cookie
eslint-plugin-unicorn
No autofix
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-document-cookie": "error",
},
},
];document.cookie =
'foo=bar' +
'; Path=/' +
'; Domain=example.com' +
'; expires=Fri, 31 Dec 9999 23:59:59 GMT' +
'; Secure';document.cookie += '; foo=bar';await cookieStore.set({
name: 'foo',
value: 'bar',
expires: Date.now() + 24 * 60 * 60 * 1000,
domain: 'example.com'
});await cookieStore.set('foo', 'bar');import Cookies from 'js-cookie';
Cookies.set('foo', 'bar');Examples from the ESLint documentation.
unicorn/no-document-cookie
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-document-cookie": "error",
},
},
];unicorn/no-document-cookie
unicorn plugin · restriction
{
"rules": {
"unicorn/no-document-cookie": "error"
}
}suspicious/noDocumentCookie
suspicious · since 1.9.4
{
"linter": {
"rules": {
"suspicious": {
"noDocumentCookie": "error"
}
}
}
}Do not use leading/trailing space between console.log parameters.
Disallow a magic number as the depth argument in Array#flat(…).
Prefer passing Date directly to the constructor when cloning.
Disallow useless case in switch statements.
Prefer .flatMap(…) over .map(…).flat() and .filter(…).flatMap(…).
Prefer Array#{indexOf,lastIndexOf}() over Array#{findIndex,findLastIndex}() when looking for the index of an item.