mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-03-25 12:48:12 +00:00
Merge branch 'master' into issue_3659
This commit is contained in:
@@ -1,48 +1,48 @@
|
|||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"stylelint-config-recess-order",
|
"stylelint-config-recess-order",
|
||||||
"stylelint-config-recommended"],
|
"stylelint-config-recommended"],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@stylistic/stylelint-plugin",
|
"@stylistic/stylelint-plugin",
|
||||||
"./stylelint_plugins/declaration-colon-align.js",
|
"./stylelint_plugins/declaration-colon-align.js",
|
||||||
"./stylelint_plugins/declaration-colon-min-space-before",
|
"./stylelint_plugins/declaration-colon-min-space-before",
|
||||||
"./stylelint_plugins/declaration-block-multi-line-min-declarations"
|
"./stylelint_plugins/declaration-block-multi-line-min-declarations"
|
||||||
],
|
],
|
||||||
"customSyntax": "postcss-less",
|
"customSyntax": "postcss-less",
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-descending-specificity" : null,
|
"no-descending-specificity" : null,
|
||||||
"at-rule-no-unknown" : null,
|
"at-rule-no-unknown" : null,
|
||||||
"function-no-unknown" : null,
|
"function-no-unknown" : null,
|
||||||
"font-family-no-missing-generic-family-keyword" : null,
|
"font-family-no-missing-generic-family-keyword" : null,
|
||||||
"font-weight-notation" : "named-where-possible",
|
"font-weight-notation" : "named-where-possible",
|
||||||
"font-family-name-quotes" : "always-unless-keyword",
|
"font-family-name-quotes" : "always-unless-keyword",
|
||||||
"@stylistic/indentation" : "tab",
|
"@stylistic/indentation" : "tab",
|
||||||
"no-duplicate-selectors" : true,
|
"no-duplicate-selectors" : true,
|
||||||
"@stylistic/color-hex-case" : "upper",
|
"@stylistic/color-hex-case" : "upper",
|
||||||
"color-hex-length" : "long",
|
"color-hex-length" : "long",
|
||||||
"@stylistic/selector-combinator-space-after" : "always",
|
"@stylistic/selector-combinator-space-after" : "always",
|
||||||
"@stylistic/selector-combinator-space-before" : "always",
|
"@stylistic/selector-combinator-space-before" : "always",
|
||||||
"@stylistic/selector-attribute-operator-space-before" : "never",
|
"@stylistic/selector-attribute-operator-space-before" : "never",
|
||||||
"@stylistic/selector-attribute-operator-space-after" : "never",
|
"@stylistic/selector-attribute-operator-space-after" : "never",
|
||||||
"@stylistic/selector-attribute-brackets-space-inside" : "never",
|
"@stylistic/selector-attribute-brackets-space-inside" : "never",
|
||||||
"selector-attribute-quotes" : "always",
|
"selector-attribute-quotes" : "always",
|
||||||
"selector-pseudo-element-colon-notation" : "double",
|
"selector-pseudo-element-colon-notation" : "double",
|
||||||
"@stylistic/selector-pseudo-class-parentheses-space-inside" : "never",
|
"@stylistic/selector-pseudo-class-parentheses-space-inside" : "never",
|
||||||
"@stylistic/block-opening-brace-space-before" : "always",
|
"@stylistic/block-opening-brace-space-before" : "always",
|
||||||
"naturalcrit/declaration-colon-min-space-before" : 1,
|
"naturalcrit/declaration-colon-min-space-before" : 1,
|
||||||
"@stylistic/declaration-block-trailing-semicolon" : "always",
|
"@stylistic/declaration-block-trailing-semicolon" : "always",
|
||||||
"@stylistic/declaration-colon-space-after" : "always",
|
"@stylistic/declaration-colon-space-after" : "always",
|
||||||
"@stylistic/number-leading-zero" : "always",
|
"@stylistic/number-leading-zero" : "always",
|
||||||
"function-url-quotes" : ["always", { "except": ["empty"] }],
|
"function-url-quotes" : ["always", { "except": ["empty"] }],
|
||||||
"function-url-scheme-disallowed-list" : ["data","http"],
|
"function-url-scheme-disallowed-list" : ["data","http"],
|
||||||
"comment-whitespace-inside" : "always",
|
"comment-whitespace-inside" : "always",
|
||||||
"@stylistic/string-quotes" : "single",
|
"@stylistic/string-quotes" : "single",
|
||||||
"@stylistic/media-feature-range-operator-space-before" : "always",
|
"@stylistic/media-feature-range-operator-space-before" : "always",
|
||||||
"@stylistic/media-feature-range-operator-space-after" : "always",
|
"@stylistic/media-feature-range-operator-space-after" : "always",
|
||||||
"@stylistic/media-feature-parentheses-space-inside" : "never",
|
"@stylistic/media-feature-parentheses-space-inside" : "never",
|
||||||
"@stylistic/media-feature-colon-space-before" : "always",
|
"@stylistic/media-feature-colon-space-before" : "always",
|
||||||
"@stylistic/media-feature-colon-space-after" : "always",
|
"@stylistic/media-feature-colon-space-after" : "always",
|
||||||
"naturalcrit/declaration-colon-align" : true,
|
"naturalcrit/declaration-colon-align" : true,
|
||||||
"naturalcrit/declaration-block-multi-line-min-declarations": 1
|
"naturalcrit/declaration-block-multi-line-min-declarations" : 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
require('./notificationPopup.less');
|
require('./notificationPopup.less');
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import request from '../../utils/request-middleware.js';
|
import request from '../../utils/request-middleware.js';
|
||||||
|
import Markdown from 'naturalcrit/markdown.js';
|
||||||
|
|
||||||
import Dialog from '../../../components/dialog.jsx';
|
import Dialog from '../../../components/dialog.jsx';
|
||||||
|
|
||||||
@@ -40,11 +41,10 @@ const NotificationPopup = ()=>{
|
|||||||
|
|
||||||
const renderNotificationsList = ()=>{
|
const renderNotificationsList = ()=>{
|
||||||
if(error) return <div className='error'>{error}</div>;
|
if(error) return <div className='error'>{error}</div>;
|
||||||
|
|
||||||
return notifications.map((notification)=>(
|
return notifications.map((notification)=>(
|
||||||
<li key={notification.dismissKey} >
|
<li key={notification.dismissKey} >
|
||||||
<em>{notification.title}</em><br />
|
<em>{notification.title}</em><br />
|
||||||
<p dangerouslySetInnerHTML={{ __html: notification.text }}></p>
|
<p dangerouslySetInnerHTML={{ __html: Markdown.render(notification.text) }}></p>
|
||||||
</li>
|
</li>
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,17 +48,46 @@
|
|||||||
}
|
}
|
||||||
ul {
|
ul {
|
||||||
margin-top : 15px;
|
margin-top : 15px;
|
||||||
font-size : 0.8em;
|
font-size : 0.9em;
|
||||||
list-style-position : outside;
|
list-style-position : outside;
|
||||||
list-style-type : disc;
|
list-style-type : disc;
|
||||||
li {
|
li {
|
||||||
margin-top : 1.4em;
|
padding-left : 1em;
|
||||||
font-size : 0.8em;
|
margin-top : 1.5em;
|
||||||
line-height : 1.4em;
|
font-size : 0.9em;
|
||||||
|
line-height : 1.5em;
|
||||||
em {
|
em {
|
||||||
text-transform:capitalize;
|
font-weight : 800;
|
||||||
font-weight : 800;
|
text-transform : capitalize;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
margin-top : 0;
|
||||||
|
line-height : 1.2em;
|
||||||
|
list-style-type : square;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ul ul,ol ol,ul ol,ol ul {
|
||||||
|
margin-bottom : 0px;
|
||||||
|
margin-left : 1.5em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Markdown styling */
|
||||||
|
code {
|
||||||
|
padding : 0.1em 0.5em;
|
||||||
|
font-family : 'Courier New', 'Courier', monospace;
|
||||||
|
overflow-wrap : break-word;
|
||||||
|
white-space : pre-wrap;
|
||||||
|
background : #08115A;
|
||||||
|
border-radius : 2px;
|
||||||
|
}
|
||||||
|
pre code {
|
||||||
|
display : inline-block;
|
||||||
|
width : 100%;
|
||||||
|
}
|
||||||
|
.blank {
|
||||||
|
height : 1em;
|
||||||
|
margin-top : 0;
|
||||||
|
& + * { margin-top : 0; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
const stylelint = require('stylelint');
|
import stylelint from 'stylelint';
|
||||||
const { isNumber } = require('stylelint/lib/utils/validateTypes.cjs');
|
import { isNumber } from 'stylelint/lib/utils/validateTypes.mjs';
|
||||||
|
|
||||||
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
||||||
const ruleName = 'naturalcrit/declaration-block-multi-line-min-declarations';
|
const ruleName = 'naturalcrit/declaration-block-multi-line-min-declarations';
|
||||||
@@ -7,9 +7,8 @@ const messages = ruleMessages(ruleName, {
|
|||||||
expected : (decls)=>`Rule with ${decls} declaration${decls == 1 ? '' : 's'} should be single line`,
|
expected : (decls)=>`Rule with ${decls} declaration${decls == 1 ? '' : 's'} should be single line`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ruleFunction = (primaryOption, secondaryOptionObject, context)=>{
|
||||||
module.exports = stylelint.createPlugin(ruleName, function getPlugin(primaryOption, secondaryOptionObject, context) {
|
return (postcssRoot, postcssResult)=>{
|
||||||
return function lint(postcssRoot, postcssResult) {
|
|
||||||
|
|
||||||
const validOptions = validateOptions(
|
const validOptions = validateOptions(
|
||||||
postcssResult,
|
postcssResult,
|
||||||
@@ -20,26 +19,23 @@ module.exports = stylelint.createPlugin(ruleName, function getPlugin(primaryOpti
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!validOptions) { //If the options are invalid, don't lint
|
if(!validOptions) //If the options are invalid, don't lint
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
const isAutoFixing = Boolean(context.fix);
|
const isAutoFixing = Boolean(context.fix);
|
||||||
|
|
||||||
postcssRoot.walkRules((rule)=>{ //Iterate CSS rules
|
postcssRoot.walkRules((rule)=>{ //Iterate CSS rules
|
||||||
|
|
||||||
//Apply rule only if all children are decls (no further nested rules)
|
//Apply rule only if all children are decls (no further nested rules)
|
||||||
if(rule.nodes.length > primaryOption || !rule.nodes.every((node)=>node.type === 'decl')) {
|
if(rule.nodes.length > primaryOption || !rule.nodes.every((node)=>node.type === 'decl'))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
//Ignore if already one line
|
//Ignore if already one line
|
||||||
if(!rule.nodes.some((node)=>node.raws.before.includes('\n')) && !rule.raws.after.includes('\n'))
|
if(!rule.nodes.some((node)=>node.raws.before.includes('\n')) && !rule.raws.after.includes('\n'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(isAutoFixing) { //We are in “fix” mode
|
if(isAutoFixing) { //We are in “fix” mode
|
||||||
rule.each((decl)=>{
|
rule.each((decl)=>decl.raws.before = ' ');
|
||||||
decl.raws.before = ' ';
|
|
||||||
});
|
|
||||||
rule.raws.after = ' ';
|
rule.raws.after = ' ';
|
||||||
} else {
|
} else {
|
||||||
report({
|
report({
|
||||||
@@ -52,7 +48,9 @@ module.exports = stylelint.createPlugin(ruleName, function getPlugin(primaryOpti
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
|
|
||||||
module.exports.ruleName = ruleName;
|
ruleFunction.ruleName = ruleName;
|
||||||
module.exports.messages = messages;
|
ruleFunction.messages = messages;
|
||||||
|
|
||||||
|
export default stylelint.createPlugin(ruleName, ruleFunction);
|
||||||
|
|||||||
@@ -1,32 +1,29 @@
|
|||||||
const stylelint = require('stylelint');
|
import stylelint from 'stylelint';
|
||||||
|
|
||||||
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
||||||
|
|
||||||
const ruleName = 'naturalcrit/declaration-colon-align';
|
const ruleName = 'naturalcrit/declaration-colon-align';
|
||||||
const messages = ruleMessages(ruleName, {
|
const messages = ruleMessages(ruleName, {
|
||||||
expected : (rule)=>`Expected colons aligned within rule "${rule}"`,
|
expected : (rule)=>`Expected colons aligned within rule "${rule}"`,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ruleFunction = (primaryOption, secondaryOptionObject, context)=>{
|
||||||
module.exports = stylelint.createPlugin(ruleName, function getPlugin(primaryOption, secondaryOptionObject, context) {
|
return (postcssRoot, postcssResult)=>{
|
||||||
return function lint(postcssRoot, postcssResult) {
|
|
||||||
|
|
||||||
const validOptions = validateOptions(
|
const validOptions = validateOptions(
|
||||||
postcssResult,
|
postcssResult,
|
||||||
ruleName,
|
ruleName,
|
||||||
{
|
{
|
||||||
actual : primaryOption,
|
actual : primaryOption,
|
||||||
possible : [
|
possible : [true, false]
|
||||||
true,
|
|
||||||
false
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!validOptions) { //If the options are invalid, don't lint
|
if(!validOptions) // If the options are invalid, don't lint
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
const isAutoFixing = Boolean(context.fix);
|
const isAutoFixing = Boolean(context.fix);
|
||||||
postcssRoot.walkRules((rule)=>{ //Iterate CSS rules
|
|
||||||
|
postcssRoot.walkRules((rule)=>{ // Iterate CSS rules
|
||||||
|
|
||||||
let maxColonPos = 0;
|
let maxColonPos = 0;
|
||||||
let misaligned = false;
|
let misaligned = false;
|
||||||
@@ -36,33 +33,37 @@ module.exports = stylelint.createPlugin(ruleName, function getPlugin(primaryOpti
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const colonPos = declaration.prop.length + declaration.raws.between.indexOf(':');
|
const colonPos = declaration.prop.length + declaration.raws.between.indexOf(':');
|
||||||
if(maxColonPos > 0 && colonPos != maxColonPos) {
|
|
||||||
|
if(maxColonPos > 0 && colonPos != maxColonPos)
|
||||||
misaligned = true;
|
misaligned = true;
|
||||||
}
|
|
||||||
maxColonPos = Math.max(maxColonPos, colonPos);
|
maxColonPos = Math.max(maxColonPos, colonPos);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(misaligned) {
|
if(!misaligned)
|
||||||
if(isAutoFixing) { //We are in “fix” mode
|
return;
|
||||||
rule.each((declaration)=>{
|
|
||||||
if(declaration.type != 'decl')
|
|
||||||
return;
|
|
||||||
|
|
||||||
declaration.raws.between = `${' '.repeat(maxColonPos - declaration.prop.length)}:${declaration.raws.between.split(':')[1]}`;
|
if(isAutoFixing) { // We are in “fix” mode
|
||||||
});
|
rule.each((declaration)=>{
|
||||||
} else { //We are in “report only” mode
|
if(declaration.type != 'decl')
|
||||||
report({
|
return;
|
||||||
ruleName,
|
|
||||||
result : postcssResult,
|
declaration.raws.between = `${' '.repeat(maxColonPos - declaration.prop.length)}:${declaration.raws.between.split(':')[1]}`;
|
||||||
message : messages.expected(rule.selector), // Build the reported message
|
});
|
||||||
node : rule, // Specify the reported node
|
} else { // We are in “report only” mode
|
||||||
word : rule.selector, // Which exact word caused the error? This positions the error properly
|
report({
|
||||||
});
|
ruleName,
|
||||||
}
|
result : postcssResult,
|
||||||
|
message : messages.expected(rule.selector), // Build the reported message
|
||||||
|
node : rule, // Specify the reported node
|
||||||
|
word : rule.selector, // Which exact word caused the error? This positions the error properly
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
|
|
||||||
module.exports.ruleName = ruleName;
|
ruleFunction.ruleName = ruleName;
|
||||||
module.exports.messages = messages;
|
ruleFunction.messages = messages;
|
||||||
|
|
||||||
|
export default stylelint.createPlugin(ruleName, ruleFunction);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
const stylelint = require('stylelint');
|
import stylelint from 'stylelint';
|
||||||
const { isNumber } = require('stylelint/lib/utils/validateTypes.cjs');
|
import { isNumber } from 'stylelint/lib/utils/validateTypes.mjs';
|
||||||
|
|
||||||
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
const { report, ruleMessages, validateOptions } = stylelint.utils;
|
||||||
const ruleName = 'naturalcrit/declaration-colon-min-space-before';
|
const ruleName = 'naturalcrit/declaration-colon-min-space-before';
|
||||||
@@ -7,9 +7,8 @@ const messages = ruleMessages(ruleName, {
|
|||||||
expected : (num)=>`Expected at least ${num} space${num == 1 ? '' : 's'} before ":"`
|
expected : (num)=>`Expected at least ${num} space${num == 1 ? '' : 's'} before ":"`
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ruleFunction = (primaryOption, secondaryOptionObject, context)=>{
|
||||||
module.exports = stylelint.createPlugin(ruleName, function getPlugin(primaryOption, secondaryOptionObject, context) {
|
return (postcssRoot, postcssResult)=>{
|
||||||
return function lint(postcssRoot, postcssResult) {
|
|
||||||
|
|
||||||
const validOptions = validateOptions(
|
const validOptions = validateOptions(
|
||||||
postcssResult,
|
postcssResult,
|
||||||
@@ -30,9 +29,9 @@ module.exports = stylelint.createPlugin(ruleName, function getPlugin(primaryOpti
|
|||||||
const between = decl.raws.between;
|
const between = decl.raws.between;
|
||||||
const colonIndex = between.indexOf(':');
|
const colonIndex = between.indexOf(':');
|
||||||
|
|
||||||
if(between.slice(0, colonIndex).length >= primaryOption) {
|
if(between.slice(0, colonIndex).length >= primaryOption)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if(isAutoFixing) { //We are in “fix” mode
|
if(isAutoFixing) { //We are in “fix” mode
|
||||||
decl.raws.between = between.slice(0, colonIndex).replace(/\s*$/, ' '.repeat(primaryOption)) + between.slice(colonIndex);
|
decl.raws.between = between.slice(0, colonIndex).replace(/\s*$/, ' '.repeat(primaryOption)) + between.slice(colonIndex);
|
||||||
} else {
|
} else {
|
||||||
@@ -46,7 +45,9 @@ module.exports = stylelint.createPlugin(ruleName, function getPlugin(primaryOpti
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
};
|
||||||
|
|
||||||
module.exports.ruleName = ruleName;
|
ruleFunction.ruleName = ruleName;
|
||||||
module.exports.messages = messages;
|
ruleFunction.messages = messages;
|
||||||
|
|
||||||
|
export default stylelint.createPlugin(ruleName, ruleFunction);
|
||||||
Reference in New Issue
Block a user