Bug 1867560 [wpt PR 43456] - [FLEDGE]: Add allSlotsRequestedSizes to AuctionConfig...
[gecko.git] / .stylelintrc.js
blobf535e50146c3986c39e6691f2f4baa422eb591ec
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           "add" /* Used in mathml.css */,
51         ],
52       },
53     ],
55     "max-nesting-depth": [
56       3,
57       {
58         ignore: ["blockless-at-rules"],
59       },
60     ],
62     "no-descending-specificity": null,
63     "no-duplicate-selectors": null,
65     "property-no-unknown": [
66       true,
67       {
68         ignoreProperties: ["overflow-clip-box"],
69       },
70     ],
72     /*
73      * XXXgijs: we would like to enable this, but we can't right now.
74      * This is because Gecko uses a number of custom pseudoclasses,
75      * and stylelint assumes that for `:unknown-pseudoclass(foo)`,
76      * `foo` should be a known type.
77      * This is tedious but workable for things like `-moz-locale-dir` where
78      * the set of acceptable values (ltr/rtl) is small.
79      * However, for tree cells, the set of values is unlimited (ie
80      * user-defined, based on atoms sent by the JS tree view APIs).
81      * There does not appear to be a way to exempt the contents of these
82      * unknown pseudoclasses, and as a result, this rule is not
83      * usable for us. The 'type' only includes the contents of the
84      * pseudoclass, not the pseudo itself, so we can't filter based on the
85      * pseudoclass either.
86      * Ideally, we would either create an option to the builtin rule
87      * in stylelint itself, or mimic the rule but exempt these, or
88      * add parser support for our custom pseudoclasses.
89      *
90      * For now, we just disable this rule.
91      */
92     "selector-type-no-unknown": null,
93     /*
94      * See above - if we enabled this rule, we'd have to allow for a number
95      * of custom elements we use, which are listed here:
96     "selector-type-no-unknown": [
97       true,
98       {
99         ignore: ["custom-elements"],
100         ignoreTypes: [
101           // Modern custom element / storybooked components:
102           /^moz-/,
103           // moz-locale-dir trips this rule for some reason:
104           "rtl",
105           "ltr",
106           // Migrated XBL elements not part of core XUL that we use at the moment:
107           "findbar",
108           "panelmultiview",
109           "panelview",
110           "popupnotification",
111           "popupnotificationcontent",
112           // Legacy XUL elements:
113           // (the commented out ones used to be a thing and aren't used in-tree anymore)
114           "arrowscrollbox",
115           "box",
116           // "broadcaster",
117           // "broadcasterset",
118           "button",
119           "browser",
120           "checkbox",
121           "caption",
122           // clicktoscroll
123           // colorpicker
124           // column
125           // columns
126           "commandset",
127           "command",
128           // conditions
129           // content
130           // datepicker
131           "deck",
132           "description",
133           "dialog",
134           // dialogheader
135           "dropmarker",
136           "editor",
137           // grid
138           // grippy
139           "groupbox",
140           "hbox",
141           // iframe
142           // image
143           "key",
144           "keyset",
145           // label
146           "listbox",
147           // listcell
148           // listcol
149           // listcols
150           // listhead
151           // listheader
152           "listitem",
153           // member
154           "menu",
155           "menubar",
156           "menucaption",
157           "menuitem",
158           "menulist",
159           "menupopup",
160           "menuseparator",
161           "notification",
162           "notificationbox",
163           "observes",
164           // overlay
165           // page
166           "panel",
167           // param
168           "popupset",
169           // preference
170           // preferences
171           // prefpane
172           // prefwindow
173           // progressmeter
174           // query
175           // queryset
176           "radio",
177           "radiogroup",
178           // resizer
179           "richlistbox",
180           "richlistitem",
181           // row
182           // rows
183           // rule
184           // scale
185           // script
186           "scrollbar",
187           "scrollbox",
188           "scrollcorner",
189           "separator",
190           "spacer",
191           // spinbuttons
192           "splitter",
193           "stack",
194           // statusbar
195           // statusbarpanel
196           "stringbundle",
197           "stringbundleset",
198           "tab",
199           "tabbox",
200           "tabpanel",
201           "tabpanels",
202           "tabs",
203           // template
204           // textnode
205           "textbox",
206           // timepicker
207           "titlebar",
208           "toolbar",
209           "toolbarbutton",
210           // toolbargrippy
211           "toolbaritem",
212           "toolbarpalette",
213           "toolbarpaletteitem",
214           "toolbarseparator",
215           "toolbarset",
216           "toolbarspacer",
217           "toolbarspring",
218           "toolbartabstop",
219           "toolbox",
220           "tooltip",
221           "tree",
222           "treecell",
223           "treechildren",
224           "treecol",
225           "treecols",
226           "treeitem",
227           "treerow",
228           "treeseparator",
229           // triple
230           "vbox",
231           // where
232           "window",
233           "wizard",
234           "wizardpage",
235         ],
236       },
237     ],
238     */
240     "selector-pseudo-class-no-unknown": [
241       true,
242       {
243         ignorePseudoClasses: ["popover-open"],
244       },
245     ],
246     "selector-pseudo-element-no-unknown": [
247       true,
248       {
249         ignorePseudoElements: ["slider-track", "slider-fill", "slider-thumb"],
250       },
251     ],
252   },
254   overrides: [
255     {
256       files: "*.scss",
257       customSyntax: "postcss-scss",
258       extends: "stylelint-config-recommended-scss",
259     },
260     {
261       files: [
262         "browser/components/aboutwelcome/**",
263         "browser/components/newtab/**",
264       ],
265       customSyntax: "postcss-scss",
266       extends: "stylelint-config-standard-scss",
267       rules: {
268         "at-rule-disallowed-list": [
269           ["debug", "warn", "error"],
270           {
271             message: "Clean up %s directives before committing",
272           },
273         ],
274         "at-rule-no-vendor-prefix": null,
275         "color-function-notation": null,
276         "color-hex-case": "upper",
277         "comment-empty-line-before": [
278           "always",
279           {
280             except: ["first-nested"],
281             ignore: ["after-comment", "stylelint-commands"],
282           },
283         ],
284         "custom-property-empty-line-before": null,
285         "custom-property-pattern": null,
286         "declaration-block-no-duplicate-properties": true,
287         "declaration-block-no-redundant-longhand-properties": null,
288         "declaration-no-important": true,
289         "function-no-unknown": [
290           true,
291           {
292             ignoreFunctions: ["div"],
293           },
294         ],
295         "function-url-no-scheme-relative": true,
296         indentation: 2,
297         "keyframes-name-pattern": null,
298         "media-feature-name-no-vendor-prefix": null,
299         "no-descending-specificity": null,
300         "no-eol-whitespace": true,
301         "no-missing-end-of-source-newline": true,
302         "number-leading-zero": "always",
303         "number-no-trailing-zeros": true,
304         "property-disallowed-list": [
305           ["margin-left", "margin-right"],
306           {
307             message: "Use margin-inline instead of %s",
308           },
309         ],
310         "property-no-unknown": true,
311         "property-no-vendor-prefix": null,
312         "scss/dollar-variable-empty-line-before": null,
313         "scss/double-slash-comment-empty-line-before": [
314           "always",
315           {
316             except: ["first-nested"],
317             ignore: ["between-comments", "stylelint-commands", "inside-block"],
318           },
319         ],
320         "selector-class-pattern": null,
321         "selector-no-vendor-prefix": null,
322         "string-quotes": [
323           "single",
324           {
325             avoidEscape: true,
326           },
327         ],
328         "value-keyword-case": null,
329         "value-no-vendor-prefix": null,
330       },
331     },
332   ],