fix: standardize punctuation

This commit is contained in:
Linus Rath
2026-04-16 19:07:42 +02:00
parent 6b57118add
commit 8bdadc7ba3
107 changed files with 452 additions and 448 deletions
+4 -4
View File
@@ -19,7 +19,7 @@ function makeBulwarkRule(overrides: Partial<FilterRule> = {}): FilterRule {
}
describe('external rule preservation (issue #201)', () => {
describe('parser external rule recognition', () => {
describe('parser - external rule recognition', () => {
it('parses a Roundcube-style rule with "# rule:[Name]" comment', () => {
const script = `require ["fileinto"];\n\n# rule:[Archive Newsletters]\nif header :contains "List-Id" "news" {\n fileinto "Newsletters";\n}\n`;
const result = parseScript(script);
@@ -84,7 +84,7 @@ describe('external rule preservation (issue #201)', () => {
});
});
describe('parser mixed Bulwark + external', () => {
describe('parser - mixed Bulwark + external', () => {
it('returns Bulwark rules from metadata and external rules from the rest', () => {
const bulwark = [makeBulwarkRule({ name: 'Bulwark A' })];
const bulwarkScript = generateScript(bulwark);
@@ -113,7 +113,7 @@ describe('external rule preservation (issue #201)', () => {
});
});
describe('generator external splice', () => {
describe('generator - external splice', () => {
it('appends external rawBlocks verbatim after Bulwark-managed output', () => {
const externalRule: FilterRule = {
id: 'ext-0',
@@ -253,7 +253,7 @@ describe('external rule preservation (issue #201)', () => {
const externalBefore = parsed.rules.filter(r => r.origin === 'external');
expect(externalBefore).toHaveLength(1);
// Simulate a user edit update the Bulwark rule name
// Simulate a user edit - update the Bulwark rule name
const edited = parsed.rules.map(r => (r.origin === 'external' || r.origin === 'opaque' ? r : { ...r, name: 'Mine (edited)' }));
const regenerated = generateScript(edited, parsed.vacation, { externalRequires: parsed.externalRequires });
const reparsed = parseScript(regenerated);
@@ -17,7 +17,7 @@ if anyof(header :is "From" "ceo@company.com", header :is "From" "board@company.c
# --- External rules (managed outside Bulwark) ---
# rule:[Finance auto-file invoices]
# rule:[Finance - auto-file invoices]
if allof(header :contains "From" "billing@", header :contains "Subject" "invoice") {
fileinto :copy "Finance/Invoices";
keep;
+4 -4
View File
@@ -233,7 +233,7 @@ function extractRequireTokens(stmt: string): string[] {
/**
* Extract the last contiguous block of comments immediately preceding a
* statement comments separated from the statement by a blank line are not
* statement - comments separated from the statement by a blank line are not
* considered its leading commentary (they likely belong to the previous
* block, e.g. a trailing "# Nextcloud Mail - end" marker).
*/
@@ -341,7 +341,7 @@ function parseAtom(raw: string): FilterCondition | null {
} else if (tag === 'is') {
comparator = negated ? 'not_is' : 'is';
} else {
// :matches distinguish starts_with / ends_with / matches
// :matches - distinguish starts_with / ends_with / matches
const starPositions = [...value].reduce<number[]>((acc, ch, idx) => (ch === '*' ? [...acc, idx] : acc), []);
if (starPositions.length === 1 && starPositions[0] === value.length - 1) {
comparator = 'starts_with';
@@ -591,7 +591,7 @@ export function parseScript(content: string): ParseResult {
};
}
// No metadata check vacation-only first
// No metadata - check vacation-only first
const vacationOnly = detectVacationOnlyScript(content);
if (vacationOnly) return vacationOnly;
@@ -599,7 +599,7 @@ export function parseScript(content: string): ParseResult {
const external = parseExternalRules(content, 'ext');
if (!external.hasContent) {
// Entirely empty or whitespace/comments only treat as empty, editable.
// Entirely empty or whitespace/comments only - treat as empty, editable.
return { rules: [], isOpaque: false, externalRequires: [] };
}