PageSourceSearch

https://stylelint.io/assets/js/3ced107d.c3b75af0.js

js stylelint.io collected 2026-10-02 02:25:25 UTC 7,177 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkstylelint_io=self.webpackChunkstylelint_io||[]).push([["5065"],{4855:function(e,n,s){s.r(n),s.d(n,{metadata:function(){return r},default:function(){return u},frontMatter:function(){return t},contentTitle:function(){return o},toc:function(){return d},assets:function(){return a}});var r=JSON.parse('{"id":"user-guide/rules/string-no-newline","title":"string-no-newline","description":"Disallow invalid newlines within strings.","source":"@site/docs/user-guide/rules/string-no-newline.md","sourceDirName":"user-guide/rules","slug":"/user-guide/rules/string-no-newline","permalink":"/user-guide/rules/string-no-newline","draft":false,"unlisted":false,"editUrl":"https://github.com/stylelint/stylelint/edit/main/lib/rules/string-no-newline/README.md","tags":[],"version":"current","frontMatter":{"title":"string-no-newline","sidebar_label":"string-no-newline"},"sidebar":"docs","previous":{"title":"shorthand-property-no-redundant-values","permalink":"/user-guide/rules/shorthand-property-no-redundant-values"},"next":{"title":"syntax-string-no-invalid","permalink":"/user-guide/rules/syntax-string-no-invalid"}}'),i=s(4848),l=s(8453);let t={title:"string-no-newline",sidebar_label:"string-no-newline"},o="string-no-newline",a={},d=[{value:"Options",id:"options",level:2},{value:"<code>true</code>",id:"true",level:3},{value:"Optional secondary options",id:"optional-secondary-options",level:2},{value:"<code>ignore</code>",id:"ignore",level:3},{value:"<code>&quot;at-rule-preludes&quot;</code>",id:"at-rule-preludes",level:4},{value:"<code>&quot;declaration-values&quot;</code>",id:"declaration-values",level:4}];function c(e){let n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,l.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"string-no-newline",children:"string-no-newline"})}),"\n",(0,i.jsx)(n.p,{children:"Disallow invalid newlines within strings."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:'a {\n  content: "foo\n    bar"; }/*  \u2191\n *             \u2191\n * The newline here */\n'})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.a,{href:"https://www.w3.org/TR/CSS2/syndata.html#strings",children:"The spec"})," says this: \"A string cannot directly contain a newline. To include a newline in a string, use an escape representing the line feed character in ISO-10646 (U+000A), such as '\\A' or '\\00000a'.\" And also: \"It is possible to break strings over several lines, for aesthetic or other reasons, but in such a case the newline itself has to be escaped with a backslash (\\).\""]}),"\n",(0,i.jsxs)(n.admonition,{type:"note",children:[(0,i.jsx)(n.p,{children:"We recommend configuring this rule so that it doesn't overlap with:"}),(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"/user-guide/rules/at-rule-descriptor-value-no-unknown",children:(0,i.jsx)(n.code,{children:"at-rule-descriptor-value-no-unknown"})})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"/user-guide/rules/at-rule-prelude-no-invalid",children:(0,i.jsx)(n.code,{children:"at-rule-prelude-no-invalid"})})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"/user-guide/rules/declaration-property-value-no-unknown",children:(0,i.jsx)(n.code,{children:"declaration-property-value-no-unknown"})})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.a,{href:"/user-guide/rules/media-query-no-invalid",children:(0,i.jsx)(n.code,{children:"media-query-no-invalid"})})}),"\n"]})]}),"\n",(0,i.jsxs)(n.p,{children:["This rule doesn't have any ",(0,i.jsx)(n.a,{href:"/user-guide/configure#message",children:"message arguments"}),"."]}),"\n",(0,i.jsx)(n.h2,{id:"options",children:"Options"}),"\n",(0,i.jsx)(n.h3,{id:"true",children:(0,i.jsx)(n.code,{children:"true"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n  "string-no-newline": true\n}\n'})}),"\n",(0,i.jsx)(n.p,{children:"The following patterns are considered problems:"}),"\n",(0,i.jsxs)("div",{class:"invalid-pattern",children:[(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:'a {\n  content: "foo\n    bar";\n}\n'})}),(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:'[title="something\nis probably wrong"] {}\n'})}),(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:'a {\n  font-family: "Times\n    New\n    Roman";\n}\n'})})]}),"\n",(0,i.jsxs)(n.p,{children:["The following patterns are ",(0,i.jsx)(n.em,{children:"not"})," considered problems:"]}),"\n",(0,i.jsxs)("div",{class:"valid-pattern",children:[(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:'a {\n  content: "foo\\Abar";\n}\n'})}),(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:'a {\n  content: "foo\\\\nbar";\n}\n'})}),(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:'[title="nothing\\\n  is wrong"] {}\n'})}),(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:'a {\n  font-family: "Times New Roman";\n}\n'})})]}),"\n",(0,i.jsx)(n.h2,{id:"optional-secondary-options",children:"Optional secondary options"}),"\n",(0,i.jsx)(n.h3,{id:"ignore",children:(0,i.jsx)(n.code,{children:"ignore"})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{ "ignore": ["array", "of", "options"] }\n'})}),"\n",(0,i.jsx)(n.h4,{id:"at-rule-preludes",children:(0,i.jsx)(n.code,{children:'"at-rule-preludes"'})}),"\n",(0,i.jsx)(n.p,{children:"Ignore strings in at-rule preludes."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n  "string-no-newline": [true, { "ignore": ["at-rule-preludes"] }]\n}\n'})}),"\n",(0,i.jsxs)(n.p,{children:["The following patterns are ",(0,i.jsx)(n.em,{children:"not"})," considered problems:"]}),"\n",(0,i.jsx)("div",{class:"valid-pattern",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:"@import url('foo\n.css');\n"})})}),"\n",(0,i.jsx)(n.h4,{id:"declaration-values",children:(0,i.jsx)(n.code,{children:'"declaration-values"'})}),"\n",(0,i.jsx)(n.p,{children:"Ignore strings in declaration values."}),"\n",(0,i.jsxs)(n.p,{children:["The following patterns are ",(0,i.jsx)(n.em,{children:"not"})," considered problems:"]}),"\n",(0,i.jsx)("div",{class:"valid-pattern",children:(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-css",children:'a {\n  content: "foo\n    bar";\n}\n'})})})]})}function u(e={}){let{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},8453:function(e,n,s){s.d(n,{R:function(){return t},x:function(){return o}});var r=s(6540);let i={},l=r.createContext(i);function t(e){let n=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:t(e.components),r.createElement(l.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.