Switch from CSSLint to stylelint

This commit is contained in:
Rob Garrison 2017-08-12 21:28:44 -05:00
parent 6f2883c6d3
commit a44b4e7822
21 changed files with 101796 additions and 71 deletions

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "Проблеми", "message": "Проблеми",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "Цвят на фона", "message": "Цвят на фона",
@ -665,8 +665,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "Проблеми, намерени от <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> при следните правила:", "message": "Проблеми, намерени от <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> при следните правила:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "Значка на иконката на лентата", "message": "Значка на иконката на лентата",

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "Problémy", "message": "Problémy",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "Barva pozadí", "message": "Barva pozadí",
@ -653,8 +653,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "Problémy nalezené aplikací <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> s těmito povolenými pravidly:", "message": "Problémy nalezené aplikací <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> s těmito povolenými pravidly:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "Ikona tlačítka na panelu", "message": "Ikona tlačítka na panelu",

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "Probleme", "message": "Probleme",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "Hintergrundfarbe", "message": "Hintergrundfarbe",
@ -633,8 +633,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "Die von <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> gefunden Fehler haben die folgenden Einstellungen:", "message": "Die von <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> gefunden Fehler haben die folgenden Einstellungen:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "Badge auf dem Toolbar-Icon", "message": "Badge auf dem Toolbar-Icon",

View File

@ -339,11 +339,11 @@
}, },
"issues": { "issues": {
"message": "Issues", "message": "Issues",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"issuesHelp": { "issuesHelp": {
"message": "The issues found by <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> with these rules enabled:", "message": "The issues found by <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> with these rules enabled:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"manageFilters": { "manageFilters": {
"message": "Filters", "message": "Filters",

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "Problemas", "message": "Problemas",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "Color de fondo", "message": "Color de fondo",
@ -657,8 +657,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "Problemas encontrados por <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> con estas reglas aplicadas:", "message": "Problemas encontrados por <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> con estas reglas aplicadas:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "Distintivo en el icono de barra de herramientas", "message": "Distintivo en el icono de barra de herramientas",

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "Vead", "message": "Vead",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "Taustavärv", "message": "Taustavärv",
@ -653,8 +653,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "<a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> poolt leitud vead nende lubatud reeglitega:", "message": "<a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> poolt leitud vead nende lubatud reeglitega:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "Number tööriistaribaikoonil", "message": "Number tööriistaribaikoonil",

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "問題点", "message": "問題点",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "背景色", "message": "背景色",
@ -649,8 +649,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "これらのルールを有効にして <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> で見つかった問題:", "message": "これらのルールを有効にして <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> で見つかった問題:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "ツールバーアイコンのバッジ", "message": "ツールバーアイコンのバッジ",

View File

@ -13,7 +13,7 @@
}, },
"issues": { "issues": {
"message": "Problemen", "message": "Problemen",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"cm_tabSize": { "cm_tabSize": {
"message": "Tabgrootte", "message": "Tabgrootte",
@ -345,8 +345,8 @@
"description": "Label for the button to check all styles for updates" "description": "Label for the button to check all styles for updates"
}, },
"issuesHelp": { "issuesHelp": {
"message": "De door CSSLint gevonden problemen, <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a>, met deze ingeschakelde regels:", "message": "De door stylelint gevonden problemen, <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a>, met deze ingeschakelde regels:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"confirmNo": { "confirmNo": {
"message": "Nee", "message": "Nee",

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "Problemy", "message": "Problemy",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "Kolor tła", "message": "Kolor tła",
@ -657,8 +657,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "Problemy znalezione przez <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> z tymi włączonymi regułami:", "message": "Problemy znalezione przez <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> z tymi włączonymi regułami:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "Emblemat na ikonie paska narzędzi", "message": "Emblemat na ikonie paska narzędzi",

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "Проблемы", "message": "Проблемы",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "Цвет фона", "message": "Цвет фона",
@ -657,8 +657,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "Проблемы и предупреждения по версии <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> с данными включенными правилами:", "message": "Проблемы и предупреждения по версии <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> с данными включенными правилами:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "Бейдж на пиктограмме в тулбаре", "message": "Бейдж на пиктограмме в тулбаре",

View File

@ -13,7 +13,7 @@
}, },
"issues": { "issues": {
"message": "Проблеми", "message": "Проблеми",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"cm_tabSize": { "cm_tabSize": {
"message": "Величина картице", "message": "Величина картице",
@ -357,8 +357,8 @@
"description": "Label for the button to check all styles for updates" "description": "Label for the button to check all styles for updates"
}, },
"issuesHelp": { "issuesHelp": {
"message": "Проблем пронађен од стране <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> са овим омогућеним правилима:", "message": "Проблем пронађен од стране <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> са овим омогућеним правилима:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"confirmNo": { "confirmNo": {
"message": "Не", "message": "Не",

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "问题", "message": "问题",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "背景颜色", "message": "背景颜色",
@ -657,8 +657,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "<a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> 在已启用的这些规则中找到问题:", "message": "<a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> 在已启用的这些规则中找到问题:",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "样式计数器", "message": "样式计数器",

View File

@ -29,7 +29,7 @@
}, },
"issues": { "issues": {
"message": "問題", "message": "問題",
"description": "Label for the CSSLint issues block on the style edit page" "description": "Label for the stylelint issues block on the style edit page"
}, },
"optionsBadgeNormal": { "optionsBadgeNormal": {
"message": "背景顏色", "message": "背景顏色",
@ -661,8 +661,8 @@
"description": "Go to Options UI" "description": "Go to Options UI"
}, },
"issuesHelp": { "issuesHelp": {
"message": "由<a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a>發現啟用這些規則會產生衝突", "message": "由<a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a>發現啟用這些規則會產生衝突",
"description": "Help popup message for the CSSLint issues block on the style edit page" "description": "Help popup message for the stylelint issues block on the style edit page"
}, },
"optionsCustomizeBadge": { "optionsCustomizeBadge": {
"message": "在工具列圖示上的徽章", "message": "在工具列圖示上的徽章",

View File

@ -34,9 +34,10 @@
<script src="vendor/codemirror/addon/edit/matchbrackets.js"></script> <script src="vendor/codemirror/addon/edit/matchbrackets.js"></script>
<link rel="stylesheet" href="vendor/codemirror/addon/lint/lint.css" /> <link rel="stylesheet" href="vendor/codemirror/addon/lint/lint.css" />
<script src="vendor/csslint/csslint-worker.js"></script>
<script src="vendor/codemirror/addon/lint/lint.js"></script> <script src="vendor/codemirror/addon/lint/lint.js"></script>
<script src="vendor-overwrites/codemirror/addon/lint/css-lint.js"></script> <script src="vendor-overwrites/stylelint/stylelint-bundle.js"></script>
<script src="vendor-overwrites/codemirror/addon/lint/stylelint-config.js"></script>
<script src="vendor-overwrites/codemirror/addon/lint/stylelint.js"></script>
<link rel="stylesheet" href="vendor/codemirror/addon/hint/show-hint.css" /> <link rel="stylesheet" href="vendor/codemirror/addon/hint/show-hint.css" />
<script src="vendor/codemirror/addon/hint/show-hint.js"></script> <script src="vendor/codemirror/addon/hint/show-hint.js"></script>

View File

@ -24,6 +24,10 @@ body {
margin-top: 1rem; margin-top: 1rem;
margin-left: 1.7rem; margin-left: 1.7rem;
} }
section {
box-sizing: border-box;
width: 100%;
}
.aligned { .aligned {
display: table-row; display: table-row;
} }
@ -397,6 +401,9 @@ body[data-match-highlight="selection"] .CodeMirror-selection-highlight-scrollbar
pointer-events: all; pointer-events: all;
opacity: 1.0; opacity: 1.0;
} }
#help-popup .rules {
padding: 0 15px;
}
/************ lint ************/ /************ lint ************/
#lint { #lint {
@ -410,6 +417,7 @@ body[data-match-highlight="selection"] .CodeMirror-selection-highlight-scrollbar
border-spacing: 0; border-spacing: 0;
margin-bottom: 1rem; margin-bottom: 1rem;
line-height: 1.0; line-height: 1.0;
width: 245px;
} }
#lint table:last-child { #lint table:last-child {
margin-bottom: 0; margin-bottom: 0;
@ -440,6 +448,10 @@ body[data-match-highlight="selection"] .CodeMirror-selection-highlight-scrollbar
} }
#lint td[role="message"] { #lint td[role="message"] {
text-align: left; text-align: left;
max-width: 140px;
text-overflow: ellipsis;
white-space: pre;
overflow: hidden;
} }
/************ CSS beautifier ************/ /************ CSS beautifier ************/
@ -552,6 +564,12 @@ body[data-match-highlight="selection"] .CodeMirror-selection-highlight-scrollbar
margin-top: 1em; margin-top: 1em;
max-height: 30vh; max-height: 30vh;
} }
#lint table {
width: 100%;
}
#lint td[role="message"] {
max-width: none;
}
#sections { #sections {
padding-left: 0; padding-left: 0;
} }

View File

@ -1,5 +1,5 @@
/* eslint brace-style: 0, operator-linebreak: 0 */ /* eslint brace-style: 0, operator-linebreak: 0 */
/* global CodeMirror exports parserlib CSSLint */ /* global CodeMirror parserlib */
'use strict'; 'use strict';
let styleId = null; let styleId = null;
@ -639,7 +639,6 @@ function addSection(event, section) {
sections.appendChild(div); sections.appendChild(div);
cm = setupCodeMirror(codeElement); cm = setupCodeMirror(codeElement);
} }
div.CodeMirror = cm; div.CodeMirror = cm;
setCleanSection(div); setCleanSection(div);
return div; return div;
@ -1051,7 +1050,7 @@ function getEditorInSight(nearbyElement) {
function updateLintReport(cm, delay) { function updateLintReport(cm, delay) {
if (delay === 0) { if (delay === 0) {
// immediately show pending csslint messages in onbeforeunload and save // immediately show pending stylelint messages in onbeforeunload and save
update(cm); update(cm);
return; return;
} }
@ -1083,7 +1082,8 @@ function updateLintReport(cm, delay) {
const info = mark.__annotation; const info = mark.__annotation;
const isActiveLine = info.from.line === cm.getCursor().line; const isActiveLine = info.from.line === cm.getCursor().line;
const pos = isActiveLine ? 'cursor' : (info.from.line + ',' + info.from.ch); const pos = isActiveLine ? 'cursor' : (info.from.line + ',' + info.from.ch);
let message = escapeHtml(info.message.replace(/ at line \d.+$/, '')); const rule = info.message.substring(info.message.lastIndexOf('('), info.message.length);
let message = escapeHtml(info.message.replace(rule, ''));
if (message.length > 100) { if (message.length > 100) {
message = message.substr(0, 100) + '...'; message = message.substr(0, 100) + '...';
} }
@ -1091,14 +1091,16 @@ function updateLintReport(cm, delay) {
delete oldMarkers[pos]; delete oldMarkers[pos];
} }
newMarkers[pos] = message; newMarkers[pos] = message;
return '<tr class="' + info.severity + '">' + return `<tr class="${info.severity}">
'<td role="severity" class="CodeMirror-lint-marker-' + info.severity + '">' + <td role="severity" class="CodeMirror-lint-marker-${info.severity}" title="Rule: ${rule}">
info.severity + '</td>' + ${info.severity}
'<td role="line">' + (info.from.line + 1) + '</td>' + </td>
'<td role="sep">:</td>' + <td role="line">${info.from.line + 1}</td>
'<td role="col">' + (info.from.ch + 1) + '</td>' + <td role="sep">:</td>
'<td role="message">' + message + '</td></tr>'; <td role="col">${info.from.ch + 1}</td>
}).join('') + '</tbody>'; <td role="message" title="${message}">${message}</td>
</tr>`
}) + '</tbody>';
scopedState.markedLast = newMarkers; scopedState.markedLast = newMarkers;
fixedOldIssues |= scopedState.reportDisplayed && Object.keys(oldMarkers).length > 0; fixedOldIssues |= scopedState.reportDisplayed && Object.keys(oldMarkers).length > 0;
if (scopedState.html !== html) { if (scopedState.html !== html) {
@ -1181,13 +1183,10 @@ function toggleLintReport() {
} }
function beautify(event) { function beautify(event) {
if (exports.css_beautify) { // thanks to csslint's definition of 'exports'
doBeautify();
} else {
const script = document.head.appendChild(document.createElement('script')); const script = document.head.appendChild(document.createElement('script'));
script.src = 'vendor-overwrites/beautify/beautify-css-mod.js'; script.src = 'vendor-overwrites/beautify/beautify-css-mod.js';
script.onload = doBeautify; script.onload = doBeautify;
}
function doBeautify() { function doBeautify() {
const tabs = prefs.get('editor.indentWithTabs'); const tabs = prefs.get('editor.indentWithTabs');
const options = prefs.get('editor.beautify'); const options = prefs.get('editor.beautify');
@ -1231,7 +1230,7 @@ function beautify(event) {
[].concat.apply([], cm.doc.sel.ranges.map(r => [].concat.apply([], cm.doc.sel.ranges.map(r =>
[Object.assign({}, r.anchor), Object.assign({}, r.head)])); [Object.assign({}, r.anchor), Object.assign({}, r.head)]));
const text = cm.getValue(); const text = cm.getValue();
const newText = exports.css_beautify(text, options); const newText = css_beautify(text, options);
if (newText !== text) { if (newText !== text) {
if (!cm.beautifyChange || !cm.beautifyChange[cm.changeGeneration()]) { if (!cm.beautifyChange || !cm.beautifyChange[cm.changeGeneration()]) {
// clear the list if last change wasn't a css-beautify // clear the list if last change wasn't a css-beautify
@ -1352,7 +1351,8 @@ function initWithStyle({style, codeIsUpdated}) {
const cm = sectionDiv.CodeMirror; const cm = sectionDiv.CodeMirror;
setTimeout(() => { setTimeout(() => {
cm.setOption('lint', CodeMirror.defaults.lint); cm.setOption('lint', CodeMirror.defaults.lint);
updateLintReport(cm, 0); // update lint issue table after a short delay
updateLintReport(cm, 200);
}, prefs.get('editor.lintDelay')); }, prefs.get('editor.lintDelay'));
} }
} }
@ -1866,11 +1866,18 @@ function showKeyMapHelp() {
} }
function showLintHelp() { function showLintHelp() {
showHelp(t('issues'), t('issuesHelp') + '<ul>' + let content = t('issuesHelp') + '<ul class="rules">',
CSSLint.getRules().map(rule => rules = [];
'<li><b>' + rule.name + '</b><br>' + rule.desc + '</li>' $$('#lint td[role="severity"]').forEach(el => {
).join('') + '</ul>' const rule = el.title.replace('Rule: (', '').replace(/[()]/g, '').trim();
); if (!rules.includes(rule)) {
content += `<li>
<a target="_blank" href="https://stylelint.io/user-guide/rules/${rule}/">${rule}</a>
</li>`;
rules.push(rule);
}
});
return showHelp(t('issues'), content + '</ul>');
} }
function showRegExpTester(event, section = getSectionForChild(this)) { function showRegExpTester(event, section = getSectionForChild(this)) {

View File

@ -0,0 +1,165 @@
const stylelintConfig = {
// 'sugarss' is a indent-based syntax like Sass or Stylus
// ref: https://github.com/postcss/postcss#syntaxes
syntax: 'sugarss',
rules: {
// ** recommended rules **
// ref: https://github.com/stylelint/stylelint-config-recommended/blob/master/index.js
'at-rule-no-unknown': true,
'block-no-empty': true,
'color-no-invalid-hex': true,
'comment-no-empty': true,
'declaration-block-no-duplicate-properties': [ true, {
'ignore': ['consecutive-duplicates-with-different-values']
}],
'declaration-block-no-redundant-longhand-properties': true,
'declaration-block-no-shorthand-property-overrides': true,
'font-family-no-duplicate-names': true,
'function-calc-no-unspaced-operator': true,
'function-linear-gradient-no-nonstandard-direction': true,
'keyframe-declaration-no-important': true,
'media-feature-name-no-unknown': true,
'no-empty-source': true,
'no-extra-semicolons': true,
'no-invalid-double-slash-comments': true,
'property-no-unknown': true,
'selector-pseudo-class-no-unknown': true,
'selector-pseudo-element-no-unknown': true,
'selector-type-no-unknown': true,
'shorthand-property-no-redundant-values': true,
'string-no-newline': true,
'unit-no-unknown': true
// ** stylistic rules **
/*
'at-rule-empty-line-before': [
'always',
{
'except': [
'blockless-after-same-name-blockless',
'first-nested'
],
'ignore': [
'after-comment'
]
}
],
'at-rule-name-case': 'lower',
'at-rule-name-space-after': 'always-single-line',
'at-rule-semicolon-newline-after': 'always',
'block-closing-brace-empty-line-before': 'never',
'block-closing-brace-newline-after': 'always',
'block-closing-brace-newline-before': 'always-multi-line',
'block-closing-brace-space-before': 'always-single-line',
'block-opening-brace-newline-after': 'always-multi-line',
'block-opening-brace-space-after': 'always-single-line',
'block-opening-brace-space-before': 'always',
'color-hex-case': 'lower',
'color-hex-length': 'short',
'comment-empty-line-before': [
'always',
{
'except': [
'first-nested'
],
'ignore': [
'stylelint-commands'
]
}
],
'comment-whitespace-inside': 'always',
'custom-property-empty-line-before': [
'always',
{
'except': [
'after-custom-property',
'first-nested'
],
'ignore': [
'after-comment',
'inside-single-line-block'
]
}
],
'declaration-bang-space-after': 'never',
'declaration-bang-space-before': 'always',
'declaration-block-semicolon-newline-after': 'always-multi-line',
'declaration-block-semicolon-space-after': 'always-single-line',
'declaration-block-semicolon-space-before': 'never',
'declaration-block-single-line-max-declarations': 1,
'declaration-block-trailing-semicolon': 'always',
'declaration-colon-newline-after': 'always-multi-line',
'declaration-colon-space-after': 'always-single-line',
'declaration-colon-space-before': 'never',
'declaration-empty-line-before': [
'always',
{
'except': [
'after-declaration',
'first-nested'
],
'ignore': [
'after-comment',
'inside-single-line-block'
]
}
],
'function-comma-newline-after': 'always-multi-line',
'function-comma-space-after': 'always-single-line',
'function-comma-space-before': 'never',
'function-max-empty-lines': 0,
'function-name-case': 'lower',
'function-parentheses-newline-inside': 'always-multi-line',
'function-parentheses-space-inside': 'never-single-line',
'function-whitespace-after': 'always',
'indentation': 2,
'length-zero-no-unit': true,
'max-empty-lines': 1,
'media-feature-colon-space-after': 'always',
'media-feature-colon-space-before': 'never',
'media-feature-name-case': 'lower',
'media-feature-parentheses-space-inside': 'never',
'media-feature-range-operator-space-after': 'always',
'media-feature-range-operator-space-before': 'always',
'media-query-list-comma-newline-after': 'always-multi-line',
'media-query-list-comma-space-after': 'always-single-line',
'media-query-list-comma-space-before': 'never',
'no-eol-whitespace': true,
'no-missing-end-of-source-newline': true,
'number-leading-zero': 'always',
'number-no-trailing-zeros': true,
'property-case': 'lower',
'rule-empty-line-before': [
'always-multi-line',
{
'except': [
'first-nested'
],
'ignore': [
'after-comment'
]
}
],
'selector-attribute-brackets-space-inside': 'never',
'selector-attribute-operator-space-after': 'never',
'selector-attribute-operator-space-before': 'never',
'selector-combinator-space-after': 'always',
'selector-combinator-space-before': 'always',
'selector-descendant-combinator-no-non-space': true,
'selector-list-comma-newline-after': 'always',
'selector-list-comma-space-before': 'never',
'selector-max-empty-lines': 0,
'selector-pseudo-class-case': 'lower',
'selector-pseudo-class-parentheses-space-inside': 'never',
'selector-pseudo-element-case': 'lower',
'selector-pseudo-element-colon-notation': 'double',
'selector-type-case': 'lower',
'unit-case': 'lower',
'value-list-comma-newline-after': 'always-multi-line',
'value-list-comma-space-after': 'always-single-line',
'value-list-comma-space-before': 'never',
'value-list-max-empty-lines': 0
*/
}
};

View File

@ -0,0 +1,49 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Depends on stylelint.js from https://github.com/...
// declare global: StyleLint
(function(mod) {
if (typeof exports == 'object' && typeof module == 'object') // CommonJS
mod(require('../../lib/codemirror'));
else if (typeof define == 'function' && define.amd) // AMD
define(['../../lib/codemirror'], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
'use strict';
CodeMirror.registerHelper('lint', 'css', text => {
let found = [];
const stylelint = require('stylelint').lint;
if (!stylelint) {
return found;
}
return stylelint({
code: text,
// stylelintConfig stored in stylelint-config.js & loaded by edit.html
config: stylelintConfig
}).then(output => {
const warnings = output.results.length ? output.results[0].warnings : [],
len = warnings.length;
let i, warning;
if (len) {
for (i = 0; i < len; i++) {
warning = warnings[i];
found.push({
from: CodeMirror.Pos(warning.line - 1, warning.column - 1),
to: CodeMirror.Pos(warning.line - 1, warning.column),
message: warning.text,
severity : warning.severity
});
}
}
return found;
});
});
});

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,23 @@
Stylelint bundle file created by:
1. Installing, or having stylelint installed in any repository
(`npm install stylelint`).
2. Installing, or having browserify installed globally
(`npm install browserify`).
3. Bundle the linter by typing this into the terminal:
`browserify -r stylelint -o stylelint-bundle.js`.
4. Lastly, comment out the following lines around 94413 to 94419:
```js
/*
try {
ignoreText = fs.readFileSync(absoluteIgnoreFilePath, "utf8");
} catch (readError) {
if (readError.code !== FILE_NOT_FOUND_ERROR_CODE) throw readError;
}
*/
```
This prevents a js error when stylelint attempts to access a local file. The
other `fs.readFile` entries are not accessed because we're using stylelint's
standalone method.

23
vendor/stylelint/stylelint-mod.md vendored Normal file
View File

@ -0,0 +1,23 @@
Stylelint bundle file created by:
1. Installing, or having stylelint installed in any repository
(`npm install stylelint`).
2. Installing, or having browserify installed globally
(`npm install browserify`).
3. Bundle the linter by typing this into the terminal:
`browserify -r stylelint -o bundle.js`.
4. Lastly, comment out the following lines - around 94413 to 94419:
```js
/*
try {
ignoreText = fs.readFileSync(absoluteIgnoreFilePath, "utf8");
} catch (readError) {
if (readError.code !== FILE_NOT_FOUND_ERROR_CODE) throw readError;
}
*/
```
This prevents a js error when stylelint attempts to access a local file. The
other `fs.readFile` entries are not accessed because we're using stylelint's
standalone method.