Bug 1826982 - Provide a better error message when servers fail to start, r=Sasha
[gecko.git] / .stylelintrc.js
blobad100a24131e8d4dc4448638e3f33a286ae83ecc
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /* eslint-env node */
7 "use strict";
9 const fs = require("fs");
10 const path = require("path");
12 function readFile(path) {
13   return fs
14     .readFileSync(path, { encoding: "utf-8" })
15     .split("\n")
16     .filter(p => p && !p.startsWith("#"));
19 const ignoreFiles = [
20   ...readFile(
21     path.join(__dirname, "tools", "rewriting", "ThirdPartyPaths.txt")
22   ),
23   ...readFile(path.join(__dirname, "tools", "rewriting", "Generated.txt")),
26 module.exports = {
27   extends: ["stylelint-config-recommended"],
28   ignoreFiles,
29   rules: {
30     /* Disabled because of `-moz-element(#foo)` which gets misparsed. */
31     "color-no-invalid-hex": null,
32     "font-family-no-missing-generic-family-keyword": [
33       true,
34       {
35         ignoreFontFamilies: [
36           "-moz-button",
37           "-moz-field",
38           "-moz-fixed",
39           "-moz-list",
40           "caption",
41         ],
42       },
43     ],
45     "function-no-unknown": [
46       true,
47       {
48         ignoreFunctions: [
49           "light-dark" /* Used for color-scheme dependent colors */,
50           "-moz-image-rect" /* Used for cropping images */,
51           "add" /* Used in mathml.css */,
52         ],
53       },
54     ],
56     "no-descending-specificity": null,
57     "no-duplicate-selectors": null,
59     "property-no-unknown": [
60       true,
61       {
62         ignoreProperties: ["overflow-clip-box"],
63       },
64     ],
66     /*
67      * XXXgijs: we would like to enable this, but we can't right now.
68      * This is because Gecko uses a number of custom pseudoclasses,
69      * and stylelint assumes that for `:unknown-pseudoclass(foo)`,
70      * `foo` should be a known type.
71      * This is tedious but workable for things like `-moz-locale-dir` where
72      * the set of acceptable values (ltr/rtl) is small.
73      * However, for tree cells, the set of values is unlimited (ie
74      * user-defined, based on atoms sent by the JS tree view APIs).
75      * There does not appear to be a way to exempt the contents of these
76      * unknown pseudoclasses, and as a result, this rule is not
77      * usable for us. The 'type' only includes the contents of the
78      * pseudoclass, not the pseudo itself, so we can't filter based on the
79      * pseudoclass either.
80      * Ideally, we would either create an option to the builtin rule
81      * in stylelint itself, or mimic the rule but exempt these, or
82      * add parser support for our custom pseudoclasses.
83      *
84      * For now, we just disable this rule.
85      */
86     "selector-type-no-unknown": null,
87     /*
88      * See above - if we enabled this rule, we'd have to allow for a number
89      * of custom elements we use, which are listed here:
90     "selector-type-no-unknown": [
91       true,
92       {
93         ignore: ["custom-elements"],
94         ignoreTypes: [
95           // Modern custom element / storybooked components:
96           /^moz-/,
97           // moz-locale-dir trips this rule for some reason:
98           "rtl",
99           "ltr",
100           // Migrated XBL elements not part of core XUL that we use at the moment:
101           "findbar",
102           "panelmultiview",
103           "panelview",
104           "popupnotification",
105           "popupnotificationcontent",
106           // Legacy XUL elements:
107           // (the commented out ones used to be a thing and aren't used in-tree anymore)
108           "arrowscrollbox",
109           "box",
110           // "broadcaster",
111           // "broadcasterset",
112           "button",
113           "browser",
114           "checkbox",
115           "caption",
116           // clicktoscroll
117           // colorpicker
118           // column
119           // columns
120           "commandset",
121           "command",
122           // conditions
123           // content
124           // datepicker
125           "deck",
126           "description",
127           "dialog",
128           // dialogheader
129           "dropmarker",
130           "editor",
131           // grid
132           // grippy
133           "groupbox",
134           "hbox",
135           // iframe
136           // image
137           "key",
138           "keyset",
139           // label
140           "listbox",
141           // listcell
142           // listcol
143           // listcols
144           // listhead
145           // listheader
146           "listitem",
147           // member
148           "menu",
149           "menubar",
150           "menucaption",
151           "menuitem",
152           "menulist",
153           "menupopup",
154           "menuseparator",
155           "notification",
156           "notificationbox",
157           "observes",
158           // overlay
159           // page
160           "panel",
161           // param
162           "popupset",
163           // preference
164           // preferences
165           // prefpane
166           // prefwindow
167           // progressmeter
168           // query
169           // queryset
170           "radio",
171           "radiogroup",
172           // resizer
173           "richlistbox",
174           "richlistitem",
175           // row
176           // rows
177           // rule
178           // scale
179           // script
180           "scrollbar",
181           "scrollbox",
182           "scrollcorner",
183           "separator",
184           "spacer",
185           // spinbuttons
186           "splitter",
187           "stack",
188           // statusbar
189           // statusbarpanel
190           "stringbundle",
191           "stringbundleset",
192           "tab",
193           "tabbox",
194           "tabpanel",
195           "tabpanels",
196           "tabs",
197           // template
198           // textnode
199           "textbox",
200           // timepicker
201           "titlebar",
202           "toolbar",
203           "toolbarbutton",
204           // toolbargrippy
205           "toolbaritem",
206           "toolbarpalette",
207           "toolbarpaletteitem",
208           "toolbarseparator",
209           "toolbarset",
210           "toolbarspacer",
211           "toolbarspring",
212           "toolbartabstop",
213           "toolbox",
214           "tooltip",
215           "tree",
216           "treecell",
217           "treechildren",
218           "treecol",
219           "treecols",
220           "treeitem",
221           "treerow",
222           "treeseparator",
223           // triple
224           "vbox",
225           // where
226           "window",
227           "wizard",
228           "wizardpage",
229         ],
230       },
231     ],
232     */
234     "selector-pseudo-class-no-unknown": [
235       true,
236       {
237         ignorePseudoClasses: ["popover-open"],
238       },
239     ],
240   },
242   overrides: [
243     {
244       // TODO: Bug 1851544: Re-enable the rule or change the rule set-up.
245       files: [
246         "browser/components/newtab/content-src/aboutwelcome/aboutwelcome.scss",
247         "browser/components/newtab/content-src/asrouter/components/ModalOverlay/_ModalOverlay.scss",
248         "browser/components/newtab/content-src/asrouter/templates/SimpleBelowSearchSnippet/_SimpleBelowSearchSnippet.scss",
249         "browser/components/newtab/content-src/components/CustomizeMenu/_CustomizeMenu.scss",
250         "browser/components/newtab/content-src/components/DiscoveryStreamComponents/CardGrid/_CardGrid.scss",
251         "browser/components/newtab/content-src/components/Search/_Search.scss",
252       ],
253       rules: {
254         "media-feature-range-notation": null,
255       },
256     },
257     {
258       files: "*.scss",
259       customSyntax: "postcss-scss",
260       extends: "stylelint-config-recommended-scss",
261     },
262     {
263       files: "browser/components/newtab/**",
264       customSyntax: "postcss-scss",
265       extends: "stylelint-config-standard-scss",
266       rules: {
267         "at-rule-disallowed-list": [
268           ["debug", "warn", "error"],
269           {
270             message: "Clean up %s directives before committing",
271           },
272         ],
273         "at-rule-no-vendor-prefix": null,
274         "color-function-notation": null,
275         "color-hex-case": "upper",
276         "comment-empty-line-before": [
277           "always",
278           {
279             except: ["first-nested"],
280             ignore: ["after-comment", "stylelint-commands"],
281           },
282         ],
283         "custom-property-empty-line-before": null,
284         "custom-property-pattern": null,
285         "declaration-block-no-duplicate-properties": true,
286         "declaration-block-no-redundant-longhand-properties": null,
287         "declaration-no-important": true,
288         "function-no-unknown": [
289           true,
290           {
291             ignoreFunctions: ["div"],
292           },
293         ],
294         "function-url-no-scheme-relative": true,
295         indentation: 2,
296         "keyframes-name-pattern": null,
297         "max-nesting-depth": [
298           8,
299           {
300             ignore: ["blockless-at-rules", "pseudo-classes"],
301           },
302         ],
303         "media-feature-name-no-vendor-prefix": null,
304         "no-descending-specificity": null,
305         "no-eol-whitespace": true,
306         "no-missing-end-of-source-newline": true,
307         "number-leading-zero": "always",
308         "number-no-trailing-zeros": true,
309         "property-disallowed-list": [
310           ["margin-left", "margin-right"],
311           {
312             message: "Use margin-inline instead of %s",
313           },
314         ],
315         "property-no-unknown": true,
316         "property-no-vendor-prefix": null,
317         "scss/dollar-variable-empty-line-before": null,
318         "scss/double-slash-comment-empty-line-before": [
319           "always",
320           {
321             except: ["first-nested"],
322             ignore: ["between-comments", "stylelint-commands", "inside-block"],
323           },
324         ],
325         "selector-class-pattern": null,
326         "selector-no-vendor-prefix": null,
327         "string-quotes": [
328           "single",
329           {
330             avoidEscape: true,
331           },
332         ],
333         "value-keyword-case": null,
334         "value-no-vendor-prefix": null,
335       },
336     },
337   ],