Skip to content

Commit

Permalink
Spellcheck on CI (#6890)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Jun 5, 2023
1 parent f7b660d commit 21978e7
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .codespellrc
@@ -0,0 +1,5 @@
# -*- mode: conf -*-
[codespell]
check-filenames = true
skip = ./.git,./node_modules,./.coverage,package-lock.json
ignore-words-list = afterall
14 changes: 14 additions & 0 deletions .github/workflows/testing.yml
Expand Up @@ -48,3 +48,17 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: ./.coverage/lcov.info

spellcheck:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install codespell
run: pip install codespell

- name: Spellcheck
# Ignore a CI failure because there are false positives.
run: codespell || echo 'Fix misspells via "codespell" on your console, or ignore false positives.'
2 changes: 1 addition & 1 deletion docs/developer-guide/rules.md
Expand Up @@ -35,7 +35,7 @@ You should add test cases for all patterns that are:
You should use:

- realistic CSS, avoiding the use of ellipses
- the minimum amount of code possible, e.g. use an empty rule if targetting selectors
- the minimum amount of code possible, e.g. use an empty rule if targeting selectors
- `{}` for empty rules, rather than `{ }`
- the `a` type selector by default
- the `@media` at-rules by default
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/standalone.test.js
Expand Up @@ -167,7 +167,7 @@ it('standalone with nonexistent-file and allowEmptyInput enabled quietly exits',
expect(output).toBe('[]');
});

it('standalone with nonexistent-file and allowEmptyInput enabled (in config) quitely exits', async () => {
it('standalone with nonexistent-file and allowEmptyInput enabled (in config) quietly exits', async () => {
const { results, errored, output } = await standalone({
files: `${fixturesPath}/nonexistent-file.css`,
config: { ...configBlockNoEmpty, allowEmptyInput: true },
Expand Down
6 changes: 3 additions & 3 deletions lib/assignDisabledRanges.js
Expand Up @@ -321,10 +321,10 @@ module.exports = function assignDisabledRanges(root, result) {
function getCommandRules(command, fullText) {
// Allow for description (f.e. /* stylelint-disable a, b -- Description */).
const fullCommand = getConfigurationComment(command, configurationComment);
const splitted = fullText.slice(fullCommand.length).split(/\s-{2,}\s/u)[0];
const rulesText = fullText.slice(fullCommand.length).split(/\s-{2,}\s/u)[0];

assertString(splitted);
const rules = splitted
assertString(rulesText);
const rules = rulesText
.trim()
.split(',')
.filter(Boolean)
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/at-rule-semicolon-space-before/__tests__/index.js
Expand Up @@ -23,7 +23,7 @@ testRule({
code: '@myatrule "valuehassemicolon;" ;',
},
{
code: '@import url(http://www.example.com/alocation;withsemicolon) ;',
code: '@import url(http://www.example.com/location;withsemicolon) ;',
},
{
code: '@import /*my styles;*/ "styles/mystyle" ;',
Expand Down Expand Up @@ -95,7 +95,7 @@ testRule({
code: '@myatrule "valuehassemicolon ;";',
},
{
code: '@import url(http://www.example.com/alocation+;withsemicolon);',
code: '@import url(http://www.example.com/location+;withsemicolon);',
},
{
code: '@import /*my styles ;*/ "styles/mystyle";',
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/block-opening-brace-space-before/README.md
Expand Up @@ -182,7 +182,7 @@ color: pink;}
Given:

```json
["/fo/"]
["/for/i"]
```

The following patterns are _not_ considered problems:
Expand Down
Expand Up @@ -81,7 +81,7 @@ testRule({

testRule({
ruleName,
config: ['always', { ignoreAtRules: ['for', '/fo/', /fo/] }],
config: ['always', { ignoreAtRules: ['for', '/for/i', /for/i] }],
fix: true,

accept: [
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/color-hex-length/__tests__/index.js
Expand Up @@ -169,7 +169,7 @@ testRule(
fixed: 'a { color: #FFFFFF; }',
message: messages.expected('#FFF', '#FFFFFF'),
line: 1,
clumn: 12,
column: 12,
endLine: 1,
endColumn: 16,
},
Expand All @@ -178,7 +178,7 @@ testRule(
fixed: 'a { color: #FFffaa; }',
message: messages.expected('#Ffa', '#FFffaa'),
line: 1,
clumn: 12,
column: 12,
endLine: 1,
endColumn: 16,
},
Expand All @@ -187,7 +187,7 @@ testRule(
fixed: 'a { color: #00aa00aa; }',
message: messages.expected('#0a0a', '#00aa00aa'),
line: 1,
clumn: 12,
column: 12,
endLine: 1,
endColumn: 17,
},
Expand All @@ -196,7 +196,7 @@ testRule(
fixed: 'a { something: #ffffff, #aabbaa, #00ffAAaa; }',
message: messages.expected('#0fAa', '#00ffAAaa'),
line: 1,
clumn: 34,
column: 34,
endLine: 1,
endColumn: 39,
},
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/max-empty-lines/index.js
Expand Up @@ -77,7 +77,7 @@ const rule = (primary, secondaryOptions, context) => {
}

if (rootRawsAfter) {
// when max setted 0, should be treated as 1 in this situation.
// when max set 0, should be treated as 1 in this situation.
root.raws.after = replaceEmptyLines(primary === 0 ? 1 : primary, rootRawsAfter, true);
}
} else if (rootRawsAfter) {
Expand Down
Expand Up @@ -47,7 +47,7 @@ testRule({
description: 'Boolean context, media feature NOT in allowed list',
},
{
code: '@media (update /* pw:ned */) {}',
code: '@media (update /* pw:need */) {}',
description: 'Boolean context with colon in comments',
},
{
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/property-no-unknown/README.md
Expand Up @@ -4,7 +4,7 @@ Disallow unknown properties.

<!-- prettier-ignore -->
```css
a { heigth: 100%; }
a { height: 100%; }
/** ↑
* This property */
```
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/property-no-unknown/__tests__/index.js
Expand Up @@ -127,7 +127,7 @@ testRule({
},
{
code: '.foo { transform+: rotate(15deg); }',
description: 'Append property value with space usign +',
description: 'Append property value with space using +',
},
{
code: '.foo { transform+_: rotate(15deg); }',
Expand Down
Expand Up @@ -77,7 +77,7 @@ testRule({
endColumn: 9,
},
{
code: '[class*=te] { }',
code: '[class*=test] { }',
message: messages.rejected('*='),
line: 1,
column: 7,
Expand Down
Expand Up @@ -67,7 +67,7 @@ testRule({
endColumn: 10,
},
{
code: '[class*=te] { }',
code: '[class*=test] { }',
message: messages.rejected('*='),
line: 1,
column: 7,
Expand Down
Expand Up @@ -38,7 +38,7 @@ const rule = (primary, _secondaryOptions, context) => {
const selector = ruleNode.raws.selector ? ruleNode.raws.selector.raw : ruleNode.selector;

// Return early for selectors containing comments
// TODO: renable when parser and stylelint are compatible
// TODO: re-enable when parser and stylelint are compatible
if (selector.includes('/*')) return;

const fixedSelector = parseSelector(selector, result, ruleNode, (fullSelector) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/selector-max-id/README.md
Expand Up @@ -96,7 +96,7 @@ The following patterns are considered problems:
a:is(#foo) {}
```

The following patters are _not_ considered problems:
The following patterns are _not_ considered problems:

<!-- prettier-ignore -->
```css
Expand Down
2 changes: 1 addition & 1 deletion lib/standalone.js
Expand Up @@ -166,7 +166,7 @@ async function standalone({
fileList = fileList.concat(ALWAYS_IGNORED_GLOBS.map((glob) => `!${glob}`));
}

// do not cache if config is explicitly overrided by option
// do not cache if config is explicitly overridden by option
const useCache = cache ?? config?.cache ?? false;

if (!useCache) {
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/__tests__/validateOptions.test.js
Expand Up @@ -247,14 +247,14 @@ it('validateOptions for multiple actual/possible pairs, checking return value',
},
{
possible: ['three', 'four'],
actual: { threee: 1 },
actual: { three_: 1 },
},
);

expect(invalidOptions).toBe(false);
expect(result.warn.mock.calls[0]).toHaveLength(2);
expect(result.warn.mock.calls[0][0]).toBe('Invalid option value "onne" for rule "foo"');
expect(result.warn.mock.calls[1][0]).toBe('Invalid option value "{"threee":1}" for rule "foo"');
expect(result.warn.mock.calls[1][0]).toBe('Invalid option value "{"three_":1}" for rule "foo"');
});

describe("validateOptions with a function for 'possible'", () => {
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/isSharedLineComment.js
Expand Up @@ -12,10 +12,10 @@ const { isRoot, isComment } = require('./typeGuards');
* @param {PostcssNode | void} b
*/
function nodesShareLines(a, b) {
const aLine = a && a.source && a.source.end && a.source.end.line;
const bLine = b && b.source && b.source.start && b.source.start.line;
const endLine = a && a.source && a.source.end && a.source.end.line;
const startLine = b && b.source && b.source.start && b.source.start.line;

return aLine === bLine;
return endLine === startLine;
}

/**
Expand Down

0 comments on commit 21978e7

Please sign in to comment.