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": {
"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": {
"message": "Цвят на фона",
@ -665,8 +665,8 @@
"description": "Go to Options UI"
},
"issuesHelp": {
"message": "Проблеми, намерени от <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> при следните правила:",
"description": "Help popup message for the CSSLint issues block on the style edit page"
"message": "Проблеми, намерени от <a href='https://stylelint.io/user-guide/rules/' target='_blank'>stylelint</a> при следните правила:",
"description": "Help popup message for the stylelint issues block on the style edit page"
},
"optionsCustomizeBadge": {
"message": "Значка на иконката на лентата",
@ -764,4 +764,4 @@
"message": "Пресъздайте стила на Мрежата със Стайлус, разширението за стилове. То ви позволява лесно да инсталиране теми за много сайтове.",
"description": "Extension description"
}
}
}

View File

@ -29,7 +29,7 @@
},
"issues": {
"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": {
"message": "Barva pozadí",
@ -653,8 +653,8 @@
"description": "Go to Options UI"
},
"issuesHelp": {
"message": "Problémy nalezené aplikací <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> s těmito povolenými pravidly:",
"description": "Help popup message for the CSSLint issues block on the style edit page"
"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 stylelint issues block on the style edit page"
},
"optionsCustomizeBadge": {
"message": "Ikona tlačítka na panelu",
@ -752,4 +752,4 @@
"message": "Změňte vzhled webů pomocí správce uživatelských stylů. Stylus umožňuje snadnou instalaci vzhledů a modifikací pro spoustu webů.",
"description": "Extension description"
}
}
}

View File

@ -29,7 +29,7 @@
},
"issues": {
"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": {
"message": "Hintergrundfarbe",
@ -633,8 +633,8 @@
"description": "Go to Options UI"
},
"issuesHelp": {
"message": "Die von <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a> gefunden Fehler haben die folgenden Einstellungen:",
"description": "Help popup message for the CSSLint issues block on the style edit page"
"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 stylelint issues block on the style edit page"
},
"optionsCustomizeBadge": {
"message": "Badge auf dem Toolbar-Icon",
@ -728,4 +728,4 @@
"message": "Gestalte das Web neu mit Stylus, dem Style Manager. Stylus ermöglicht dir ganz einfach Themes und Designs für viele populäre Websites zu installieren.",
"description": "Extension description"
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@
},
"issues": {
"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": {
"message": "Tabgrootte",
@ -345,8 +345,8 @@
"description": "Label for the button to check all styles for updates"
},
"issuesHelp": {
"message": "De door CSSLint gevonden problemen, <a href='https://github.com/CSSLint/csslint' target='_blank'>CSSLint</a>, met deze ingeschakelde regels:",
"description": "Help popup message for the CSSLint issues block on the style edit page"
"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 stylelint issues block on the style edit page"
},
"confirmNo": {
"message": "Nee",
@ -396,4 +396,4 @@
"message": "Voorzie het web van een ander uiterlijk met Stylus, een gebruikersstijlbeheerder. Stylus stelt u in staat om eenvoudig thema's en stijlen te installeren voor vele populaire websites.",
"description": "Extension description"
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -34,9 +34,10 @@
<script src="vendor/codemirror/addon/edit/matchbrackets.js"></script>
<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-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" />
<script src="vendor/codemirror/addon/hint/show-hint.js"></script>

View File

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

View File

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

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.