Skip to content

Commit 44e74ac

Browse files
committed
ci: add spellcheck
1 parent d06fffb commit 44e74ac

14 files changed

+119
-26
lines changed

.github/workflows/spellcheck.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Check spelling
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
spellcheck:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: streetsidesoftware/cspell-action@v6
12+
with:
13+
incremental_files_only: false

cspell.jsonc

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
3+
"version": "0.2",
4+
"words": [
5+
"bézier",
6+
"beziers",
7+
"crosspoint",
8+
"deoptimizations",
9+
"deoptimize",
10+
"deoptimized",
11+
"fontawesome",
12+
"Fontello",
13+
"Fonticons",
14+
"frontends",
15+
"inlines",
16+
"opencollective",
17+
"subpoint",
18+
"subselector",
19+
"xast",
20+
"Xlink",
21+
// Abbreviations
22+
"elems", // elements
23+
"unenc", // unencoded
24+
// SVG Keywords
25+
"currentcolor",
26+
// SVG Nodes / Attributes and CSS Properties, including plurals
27+
"bbox",
28+
"hkern",
29+
"horiz",
30+
"hrefs",
31+
"mpath",
32+
"onbegin",
33+
"onloadedmet",
34+
"onrepeat",
35+
"panose",
36+
"stemh",
37+
"stemv",
38+
"vkern",
39+
// Software
40+
"grunt-svgmin",
41+
"Inkscape",
42+
"SVGOMG",
43+
// NPM Packages
44+
"csstree",
45+
"csswhat",
46+
// Names
47+
"André",
48+
"Baranovskiy",
49+
"Dmitry",
50+
"Keerthi",
51+
],
52+
"ignorePaths": ["*.svg.txt", "*.svg", "cspell.jsonc", "LICENSE"],
53+
"ignoreRegExpList": [
54+
"-moz", // Mozilla Firefox CSS prefix
55+
"'.+?.svg',", // path to file with .svg extension
56+
"(?:xlink|sodipodi)(?::[a-z]+)?", // https://wikipedia.org/wiki/Sodipodi
57+
"[a-z]+: '#[a-f\\d]+',", // Color names in _collection.js
58+
"[a-z]+…", // Words that have been cut off by an ellipsis
59+
"[aprs]data",
60+
"@author .+", // JSDoc author tag line, usually names
61+
"\"name\": .+", // package.json author name property
62+
"\\*\\*SVG O\\*\\*ptimizer", // README
63+
"&.+?;", // HTML entity
64+
"^svgo .+", // Command-line example of SVGO
65+
"<svg.+>", // Inline SVG in code
66+
"Atrule", // At-rule
67+
"data:image/.+", // Data URI
68+
"datauri", // Data URI
69+
"descs", // Abbreviation of "descriptions"
70+
"ENOCLS|ENOATTRS",
71+
"id=([\"']).+?\\1", // ID attribute of inline SVG
72+
"import .+", // Import statements in Javascript
73+
"newres",
74+
"nums", // Abbreviation of "numbers"
75+
"onwarn", // Rollup API,
76+
"QRAB|QRCD",
77+
"rrggbb",
78+
"sax\\..+", // Any properties of the sax API
79+
"shorthex", // Parameter of convertColors plugin
80+
],
81+
}

docs/04-plugins/cleanupIds.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ svgo:
1616
description: Elements with an ID that starts with one of these prefixes will be ignored.
1717
default: []
1818
force:
19-
description: This plugin normally does nothing if a `<script>` or `<style>` element is found. Setting this to true will bypass that behaviour, which may result in destructive changes.
19+
description: This plugin normally does nothing if a `<script>` or `<style>` element is found. Setting this to true will bypass that behavior, which may result in destructive changes.
2020
default: false
2121
defaultPlugin: true
2222
---

lib/parser.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
* @typedef {import('./types.js').XastChild} XastChild
1212
*/
1313

14-
// @ts-ignore sax will be replaced with something else later
1514
import SAX from 'sax';
1615
import { textElems } from '../plugins/_collections.js';
1716

lib/svgo.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export declare const builtinPlugins: Array<
6767
>;
6868

6969
export type Config = {
70-
/** Can be used by plugins, for example prefixids */
70+
/** Can be used by plugins, for example prefixIds */
7171
path?: string;
7272
/** Pass over SVGs multiple times to ensure all optimizations are applied. */
7373
multipass?: boolean;

lib/svgo.test.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { jest } from '@jest/globals';
22
import { optimize } from './svgo.js';
33

4-
/**
5-
* @typedef {import('../lib/types.js').Plugin} Plugin
6-
*/
7-
84
test('allow to setup default preset', () => {
95
const svg = `
106
<?xml version="1.0" encoding="utf-8"?>
@@ -353,9 +349,6 @@ test('slices long line in error code snippet', () => {
353349
test('multipass option should trigger plugins multiple times', () => {
354350
const svg = `<svg id="abcdefghijklmnopqrstuvwxyz"></svg>`;
355351
const list = [];
356-
/**
357-
* @type {Plugin<void>}
358-
*/
359352
const testPlugin = {
360353
name: 'testPlugin',
361354
fn: (_root, _params, info) => {

lib/svgo/tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const cleanupOutData = (data, params, command) => {
8989
// no extra space in front of first number
9090
if (i == 0) delimiter = '';
9191

92-
// no extra space after 'arcto' command flags(large-arc and sweep flags)
92+
// no extra space after arc command flags (large-arc and sweep flags)
9393
// a20 60 45 0 1 30 20 → a20 60 45 0130 20
9494
if (params.noSpaceAfterFlags && (command == 'A' || command == 'a')) {
9595
var pos = i % 7;

plugins/_collections.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2397,7 +2397,7 @@ export const pseudoClasses = {
23972397
'disabled',
23982398
'enabled',
23992399
'in-range',
2400-
'indetermined',
2400+
'indeterminate',
24012401
'invalid',
24022402
'optional',
24032403
'out-of-range',

plugins/cleanupAttrs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const fn = (root, params) => {
1919
enter: (node) => {
2020
for (const name of Object.keys(node.attributes)) {
2121
if (newlines) {
22-
// new line which requires a space instead of themself
22+
// new line which requires a space instead
2323
node.attributes[name] = node.attributes[name].replace(
2424
regNewlinesNeedSpace,
2525
(match, p1, p2) => p1 + ' ' + p2,

plugins/convertStyleToAttrs.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ const g = (...args) => {
1212

1313
const stylingProps = attrsGroups.presentation;
1414
const rEscape = '\\\\(?:[0-9a-f]{1,6}\\s?|\\r\\n|.)'; // Like \" or \2051. Code points consume one space.
15-
const rAttr = '\\s*(' + g('[^:;\\\\]', rEscape) + '*?)\\s*'; // attribute name like ‘fill’
16-
const rSingleQuotes = "'(?:[^'\\n\\r\\\\]|" + rEscape + ")*?(?:'|$)"; // string in single quotes: 'smth'
17-
const rQuotes = '"(?:[^"\\n\\r\\\\]|' + rEscape + ')*?(?:"|$)'; // string in double quotes: "smth"
15+
16+
/** Pattern to match attribute name like: 'fill' */
17+
const rAttr = '\\s*(' + g('[^:;\\\\]', rEscape) + '*?)\\s*';
18+
19+
/** Pattern to match string in single quotes like: 'foo' */
20+
const rSingleQuotes = "'(?:[^'\\n\\r\\\\]|" + rEscape + ")*?(?:'|$)";
21+
22+
/** Pattern to match string in double quotes like: "foo" */
23+
const rQuotes = '"(?:[^"\\n\\r\\\\]|' + rEscape + ')*?(?:"|$)';
24+
1825
const rQuotedString = new RegExp('^' + g(rSingleQuotes, rQuotes) + '$');
1926
// Parentheses, E.g.: url(data:image/png;base64,iVBO...).
2027
// ':' and ';' inside of it should be treated as is. (Just like in strings.)

0 commit comments

Comments
 (0)