stylelint 13.8.0

This commit is contained in:
tophf 2021-01-04 13:57:58 +03:00
parent 7d6b4fc8ac
commit dfb9135f6a
8 changed files with 3586 additions and 370 deletions

View File

@ -2,7 +2,9 @@
'use strict';
(() => {
const {require} = self; // self.require will be overwritten by StyleLint
const hasCurlyBraceError = warning =>
warning.text === 'Unnecessary curly bracket (CssSyntaxError)';
let sugarssFallback;
/** @namespace EditorWorker */
createWorkerApi({
@ -31,11 +33,26 @@
return result;
},
async stylelint(code, config) {
require(['/vendor/stylelint-bundle/stylelint-bundle.min']);
const {results: [res]} = await self.require('stylelint').lint({code, config});
async stylelint(opts) {
require(['/vendor/stylelint-bundle/stylelint-bundle.min']); /* global stylelint */
try {
let res;
let pass = 0;
/* sugarss is used for stylus-lang by default,
but it fails on normal css syntax so we retry in css mode. */
const isSugarSS = opts.syntax === 'sugarss';
if (sugarssFallback && isSugarSS) opts.syntax = sugarssFallback;
while (
++pass <= 2 &&
(res = (await stylelint.lint(opts)).results[0]) &&
isSugarSS && res.warnings.some(hasCurlyBraceError)
) sugarssFallback = opts.syntax = 'css';
delete res._postcssResult; // huge and unused
return res;
} catch (e) {
delete e.postcssNode; // huge, unused, non-transferable
throw e;
}
},
});
@ -59,8 +76,8 @@
const options = {};
const rxPossible = /\bpossible:("(?:[^"]*?)"|\[(?:[^\]]*?)\]|\{(?:[^}]*?)\})/g;
const rxString = /"([-\w\s]{3,}?)"/g;
for (const [id, rule] of Object.entries(self.require('stylelint').rules)) {
const ruleCode = `${rule}`;
for (const [id, rule] of Object.entries(stylelint.rules)) {
const ruleCode = `${rule()}`;
const sets = [];
let m, mStr;
while ((m = rxPossible.exec(ruleCode))) {

View File

@ -198,17 +198,19 @@ linterMan.DEFAULTS = {
stylelint: {
validMode: () => true,
getConfig: config => ({
syntax: 'sugarss',
rules: Object.assign({}, DEFAULTS.stylelint.rules, config && config.rules),
}),
async lint(text, config, mode) {
const raw = await worker.stylelint(text, config);
async lint(code, config, mode) {
const isLess = mode === 'text/x-less';
const isStylus = mode === 'stylus';
const syntax = isLess ? 'less' : isStylus ? 'sugarss' : 'css';
const raw = await worker.stylelint({code, config, syntax});
if (!raw) {
return [];
}
// Hiding the errors about "//" comments as we're preprocessing only when saving/applying
// and we can't just pre-remove the comments since "//" may be inside a string token
const slashCommentAllowed = mode === 'text/x-less' || mode === 'stylus';
const slashCommentAllowed = isLess || isStylus;
const res = [];
for (const w of raw.warnings) {
const msg = w.text.match(/^(?:Unexpected\s+)?(.*?)\s*\([^()]+\)$|$/)[1] || w.text;

3897
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@
"less-bundle": "github:openstyles/less-bundle#v0.1.0",
"lz-string-unsafe": "^1.4.4-fork-1",
"semver-bundle": "^0.1.1",
"stylelint-bundle": "^8.0.0",
"stylelint-bundle": "^13.8.0",
"stylus-lang-bundle": "github:openstyles/stylus-lang-bundle#v0.54.7",
"usercss-meta": "^0.10.0",
"webext-launch-web-auth-flow": "^0.1.0"

View File

@ -48,7 +48,7 @@ const files = {
'dist/semver.js → semver.js',
],
'stylelint-bundle': [
'stylelint-bundle.min.js',
'dist/stylelint-bundle.min.js → stylelint-bundle.min.js',
'https://github.com/stylelint/stylelint/raw/{VERSION}/LICENSE → LICENSE',
],
'stylus-lang-bundle': [

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015 - 2017 Maxime Thirouin, David Clark & Richard Hallows
Copyright (c) 2015 - present Maxime Thirouin, David Clark & Richard Hallows
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@ -1,9 +1,9 @@
## stylelint-bundle v8.0.0
## stylelint-bundle v13.8.0
Following files are downloaded from HTTP:
* LICENSE: https://github.com/stylelint/stylelint/raw/8.0.0/LICENSE
* LICENSE: https://github.com/stylelint/stylelint/raw/13.8.0/LICENSE
Following files are copied from npm (node_modules):
* stylelint-bundle.min.js
* stylelint-bundle.min.js: dist\stylelint-bundle.min.js

File diff suppressed because one or more lines are too long