diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000000..01e309ccb6 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,5 @@ +# -*- mode: conf -*- +[codespell] +check-filenames = true +skip = ./.git,./node_modules,./.coverage,package-lock.json +ignore-words-list = afterall diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2c0c67fb70..544da8088c 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -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.' diff --git a/docs/developer-guide/rules.md b/docs/developer-guide/rules.md index 0caff2a84a..1fdab2dbea 100644 --- a/docs/developer-guide/rules.md +++ b/docs/developer-guide/rules.md @@ -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 diff --git a/lib/__tests__/standalone.test.js b/lib/__tests__/standalone.test.js index 72cb1dc045..219d3876ee 100644 --- a/lib/__tests__/standalone.test.js +++ b/lib/__tests__/standalone.test.js @@ -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 }, diff --git a/lib/assignDisabledRanges.js b/lib/assignDisabledRanges.js index 4b7b6d809f..7a7d40517f 100644 --- a/lib/assignDisabledRanges.js +++ b/lib/assignDisabledRanges.js @@ -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) diff --git a/lib/rules/at-rule-semicolon-space-before/__tests__/index.js b/lib/rules/at-rule-semicolon-space-before/__tests__/index.js index 38da8161ae..1d3102b73f 100644 --- a/lib/rules/at-rule-semicolon-space-before/__tests__/index.js +++ b/lib/rules/at-rule-semicolon-space-before/__tests__/index.js @@ -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" ;', @@ -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";', diff --git a/lib/rules/block-opening-brace-space-before/README.md b/lib/rules/block-opening-brace-space-before/README.md index 1dd90510e7..82bccdc1a1 100644 --- a/lib/rules/block-opening-brace-space-before/README.md +++ b/lib/rules/block-opening-brace-space-before/README.md @@ -182,7 +182,7 @@ color: pink;} Given: ```json -["/fo/"] +["/for/i"] ``` The following patterns are _not_ considered problems: diff --git a/lib/rules/block-opening-brace-space-before/__tests__/index.js b/lib/rules/block-opening-brace-space-before/__tests__/index.js index 5df15bb104..df07c7621b 100644 --- a/lib/rules/block-opening-brace-space-before/__tests__/index.js +++ b/lib/rules/block-opening-brace-space-before/__tests__/index.js @@ -81,7 +81,7 @@ testRule({ testRule({ ruleName, - config: ['always', { ignoreAtRules: ['for', '/fo/', /fo/] }], + config: ['always', { ignoreAtRules: ['for', '/for/i', /for/i] }], fix: true, accept: [ diff --git a/lib/rules/color-hex-length/__tests__/index.js b/lib/rules/color-hex-length/__tests__/index.js index 7f41ad4b30..1d266ee22d 100644 --- a/lib/rules/color-hex-length/__tests__/index.js +++ b/lib/rules/color-hex-length/__tests__/index.js @@ -169,7 +169,7 @@ testRule( fixed: 'a { color: #FFFFFF; }', message: messages.expected('#FFF', '#FFFFFF'), line: 1, - clumn: 12, + column: 12, endLine: 1, endColumn: 16, }, @@ -178,7 +178,7 @@ testRule( fixed: 'a { color: #FFffaa; }', message: messages.expected('#Ffa', '#FFffaa'), line: 1, - clumn: 12, + column: 12, endLine: 1, endColumn: 16, }, @@ -187,7 +187,7 @@ testRule( fixed: 'a { color: #00aa00aa; }', message: messages.expected('#0a0a', '#00aa00aa'), line: 1, - clumn: 12, + column: 12, endLine: 1, endColumn: 17, }, @@ -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, }, diff --git a/lib/rules/max-empty-lines/index.js b/lib/rules/max-empty-lines/index.js index 8cb773df96..e68be55544 100644 --- a/lib/rules/max-empty-lines/index.js +++ b/lib/rules/max-empty-lines/index.js @@ -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) { diff --git a/lib/rules/media-feature-name-value-allowed-list/__tests__/index.js b/lib/rules/media-feature-name-value-allowed-list/__tests__/index.js index 3e7afdac67..398afff178 100644 --- a/lib/rules/media-feature-name-value-allowed-list/__tests__/index.js +++ b/lib/rules/media-feature-name-value-allowed-list/__tests__/index.js @@ -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', }, { diff --git a/lib/rules/property-no-unknown/README.md b/lib/rules/property-no-unknown/README.md index 9d9569e6e4..a38ee85a85 100644 --- a/lib/rules/property-no-unknown/README.md +++ b/lib/rules/property-no-unknown/README.md @@ -4,7 +4,7 @@ Disallow unknown properties. ```css -a { heigth: 100%; } +a { height: 100%; } /** ↑ * This property */ ``` diff --git a/lib/rules/property-no-unknown/__tests__/index.js b/lib/rules/property-no-unknown/__tests__/index.js index b12bb33fbe..9177da9083 100644 --- a/lib/rules/property-no-unknown/__tests__/index.js +++ b/lib/rules/property-no-unknown/__tests__/index.js @@ -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); }', diff --git a/lib/rules/selector-attribute-operator-allowed-list/__tests__/index.js b/lib/rules/selector-attribute-operator-allowed-list/__tests__/index.js index 38ae554d63..76af7c1fc6 100644 --- a/lib/rules/selector-attribute-operator-allowed-list/__tests__/index.js +++ b/lib/rules/selector-attribute-operator-allowed-list/__tests__/index.js @@ -77,7 +77,7 @@ testRule({ endColumn: 9, }, { - code: '[class*=te] { }', + code: '[class*=test] { }', message: messages.rejected('*='), line: 1, column: 7, diff --git a/lib/rules/selector-attribute-operator-disallowed-list/__tests__/index.js b/lib/rules/selector-attribute-operator-disallowed-list/__tests__/index.js index 1efdc899e9..f292fe991a 100644 --- a/lib/rules/selector-attribute-operator-disallowed-list/__tests__/index.js +++ b/lib/rules/selector-attribute-operator-disallowed-list/__tests__/index.js @@ -67,7 +67,7 @@ testRule({ endColumn: 10, }, { - code: '[class*=te] { }', + code: '[class*=test] { }', message: messages.rejected('*='), line: 1, column: 7, diff --git a/lib/rules/selector-descendant-combinator-no-non-space/index.js b/lib/rules/selector-descendant-combinator-no-non-space/index.js index 9acd4c0991..a31255e29c 100644 --- a/lib/rules/selector-descendant-combinator-no-non-space/index.js +++ b/lib/rules/selector-descendant-combinator-no-non-space/index.js @@ -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) => { diff --git a/lib/rules/selector-max-id/README.md b/lib/rules/selector-max-id/README.md index d3e6d4d142..8384479716 100644 --- a/lib/rules/selector-max-id/README.md +++ b/lib/rules/selector-max-id/README.md @@ -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: ```css diff --git a/lib/standalone.js b/lib/standalone.js index 82435f0e25..ceed4f4b24 100644 --- a/lib/standalone.js +++ b/lib/standalone.js @@ -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) { diff --git a/lib/utils/__tests__/validateOptions.test.js b/lib/utils/__tests__/validateOptions.test.js index 97f8ea13ca..b94bd1bf26 100644 --- a/lib/utils/__tests__/validateOptions.test.js +++ b/lib/utils/__tests__/validateOptions.test.js @@ -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'", () => { diff --git a/lib/utils/isSharedLineComment.js b/lib/utils/isSharedLineComment.js index 3f325cccaa..14ab57d860 100644 --- a/lib/utils/isSharedLineComment.js +++ b/lib/utils/isSharedLineComment.js @@ -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; } /**