| 1 |
/* vim:fileencoding=utf-8 |
| 2 |
* |
| 3 |
* Copyright (C) 2023 Kovid Goyal <kovid at kovidgoyal.net> |
| 4 |
* |
| 5 |
* Distributed under terms of the GPLv3 license |
| 6 |
*/ |
| 7 |
/*jshint esversion: 6 */ |
| 8 |
(function() { |
| 9 |
"use strict"; |
| 10 |
|
| 11 |
window.stylelint_results = []; |
| 12 |
|
| 13 |
window.check_css = function(src, fix) { |
| 14 |
stylelint.lint({ |
| 15 |
code: src, |
| 16 |
fix: fix, |
| 17 |
config: { |
| 18 |
rules: { |
| 19 |
'annotation-no-unknown': true, |
| 20 |
'at-rule-no-unknown': true, |
| 21 |
'block-no-empty': true, |
| 22 |
'color-no-invalid-hex': true, |
| 23 |
'comment-no-empty': true, |
| 24 |
'custom-property-no-missing-var-function': true, |
| 25 |
'declaration-block-no-duplicate-custom-properties': true, |
| 26 |
'declaration-block-no-duplicate-properties': [ |
| 27 |
true, |
| 28 |
{ |
| 29 |
ignore: ['consecutive-duplicates-with-different-values'], |
| 30 |
}, |
| 31 |
], |
| 32 |
'declaration-block-no-shorthand-property-overrides': true, |
| 33 |
'font-family-no-duplicate-names': true, |
| 34 |
'font-family-no-missing-generic-family-keyword': true, |
| 35 |
'function-calc-no-unspaced-operator': true, |
| 36 |
'function-linear-gradient-no-nonstandard-direction': true, |
| 37 |
'function-no-unknown': true, |
| 38 |
'keyframe-block-no-duplicate-selectors': true, |
| 39 |
'keyframe-declaration-no-important': true, |
| 40 |
'media-feature-name-no-unknown': true, |
| 41 |
'named-grid-areas-no-invalid': true, |
| 42 |
'no-descending-specificity': true, |
| 43 |
'no-duplicate-at-import-rules': true, |
| 44 |
'no-duplicate-selectors': true, |
| 45 |
'no-empty-source': true, |
| 46 |
'no-extra-semicolons': true, |
| 47 |
'no-invalid-double-slash-comments': true, |
| 48 |
'no-invalid-position-at-import-rule': true, |
| 49 |
'no-irregular-whitespace': true, |
| 50 |
'property-no-unknown': true, |
| 51 |
'selector-pseudo-class-no-unknown': true, |
| 52 |
'selector-pseudo-element-no-unknown': true, |
| 53 |
'selector-type-no-unknown': [ |
| 54 |
true, |
| 55 |
{ |
| 56 |
ignore: ['custom-elements'], |
| 57 |
}, |
| 58 |
], |
| 59 |
'string-no-newline': true, |
| 60 |
'unit-no-unknown': true, |
| 61 |
}, |
| 62 |
}, |
| 63 |
formatter: (results, returnValue) => { |
| 64 |
var r = results[0]; |
| 65 |
r._postcssResult = undefined; |
| 66 |
r.source = undefined; |
| 67 |
return JSON.stringify({results:r, rule_metadata: returnValue.ruleMetadata}); |
| 68 |
}, |
| 69 |
}) |
| 70 |
.then((results) => { |
| 71 |
window.stylelint_results.push({type: 'results', 'results':results}); |
| 72 |
document.title = 'checked:' + window.performance.now(); |
| 73 |
}) |
| 74 |
.catch((err) => { |
| 75 |
window.stylelint_results.push({type: 'error', 'error':'' + err}); |
| 76 |
console.error(err.stack); |
| 77 |
document.title = 'checked:' + window.performance.now(); |
| 78 |
}) ; |
| 79 |
}; |
| 80 |
|
| 81 |
window.get_css_results = function(src) { |
| 82 |
var ans = window.stylelint_results; |
| 83 |
window.stylelint_results = []; |
| 84 |
return ans; |
| 85 |
}; |
| 86 |
document.title = 'ready:' + window.performance.now(); |
| 87 |
})(); |
| 88 |
|
| 89 |
|