Skip to content

Commit

Permalink
Merge branch 'master' into browser-bundle
Browse files Browse the repository at this point in the history
* master: (46 commits)
  Update CHANGELOG.md
  Add ignoreAtRules to property-no-unknown (#4965)
  Bump eslint from 7.11.0 to 7.12.1 (#5017)
  Bump typescript from 4.0.3 to 4.0.5 (#5016)
  Bump lint-staged from 10.4.0 to 10.5.1 (#5014)
  Bump remark-cli from 8.0.1 to 9.0.0 (#4996)
  Bump jest-circus from 26.5.3 to 26.6.1 (#5009)
  Bump got from 11.7.0 to 11.8.0 (#5007)
  Bump jest from 26.5.3 to 26.6.1 (#5008)
  Refactor formatter tests (#4988)
  Fix `isStandardSyntaxDeclaration.test.js` that use callbacks (#4972)
  Update CHANGELOG.md
  Add "comment-pattern" rule (#4962)
  Update CHANGELOG.md
  Show the pattern in "*-pattern" rule messages (#4975)
  Enable ESLint `no-shadow` and add disable comments (#4986)
  Report disables in the same manner as lints (#4973)
  Update dependencies (#4982)
  Fix some tests that use callbacks (#4970)
  Use own vendor utility instead of PostCSS (#4942) (#4963)
  ...
  • Loading branch information
m-allanson committed Nov 5, 2020
2 parents 1d7a889 + 5a84657 commit d9f9b80
Show file tree
Hide file tree
Showing 210 changed files with 4,467 additions and 4,587 deletions.
9 changes: 0 additions & 9 deletions .dependabot/config.yml

This file was deleted.

10 changes: 10 additions & 0 deletions .github/dependabot.yml
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: weekly
open-pull-requests-limit: 5
labels:
- 'pr: dependencies'
versioning-strategy: increase
1 change: 0 additions & 1 deletion .github/workflows/code-scanning.yml
Expand Up @@ -27,7 +27,6 @@ jobs:
- name: Initialize CodeQL
uses: github/codeql-action/init@v1


# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
node: [12]
node: [14]
os: [ubuntu-latest]

steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/testing.yml
Expand Up @@ -21,11 +21,11 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [10, 12]
node: [10, 12, 14]
os: [ubuntu-latest, windows-latest, macos-latest]
exclude:
- os: ubuntu-latest
node: 12
node: 14

steps:
- uses: actions/checkout@v2
Expand All @@ -51,7 +51,7 @@ jobs:

strategy:
matrix:
node: [12]
node: [14]
os: [ubuntu-latest]

steps:
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project are documented in this file.

## Head

- Added: disable comments that are reported as errors for various reasons are now reported as standard lint errors rather than a separate class of errors that must be handled specially ([#4973](https://github.com/stylelint/stylelint/pull/4973)).
- Added: configured pattern in `*-pattern` rules violation message ([#4975](https://github.com/stylelint/stylelint/pull/4975)).
- Added: `comment-pattern` rule ([#4962](https://github.com/stylelint/stylelint/pull/4962)).
- Added: `ignoreAtRules[]` to `property-no-unknown` ([#4965](https://github.com/stylelint/stylelint/pull/4965)).
- Deprecated: `StylelintStandaloneReturnValue.reportedDisables`, `.descriptionlessDisables`, `.needlessDisables`, and `.invalidScopeDisables`. `.reportedDisables` will always be empty and the other properties will always be undefined, since these errors now show up in `.results` instead ([#4973](https://github.com/stylelint/stylelint/pull/4973)).

## 13.7.2

- Fixed: regression for disable commands and adjacent double-slash comments ([#4950](https://github.com/stylelint/stylelint/pull/4950)).
- Fixed: use of full file path without converting it to glob ([#4931](https://github.com/stylelint/stylelint/pull/4931)).

## 13.7.1

- Fixed: double-slash disable comments when followed by another comment ([#4913](https://github.com/stylelint/stylelint/pull/4913)).

## 13.7.0
Expand Down
24 changes: 0 additions & 24 deletions docs/developer-guide/formatters.md
Expand Up @@ -50,30 +50,6 @@ And the second argument (`returnValue`) is an object (type `StylelintStandaloneR
```js
{
"errored": false, // `true` if there were any warnings with "error" severity
"needlessDisables": [
// Present if stylelint was configured with `reportNeedlessDisables: true`
{
"source": "path/to/file.css",
"ranges": [
{
"start": 10,
"rule": "indentation"
}
]
}
],
"invalidScopeDisables": [
// Present if stylelint was configured with `reportInvalidScopeDisables: true`
{
"source": "path/to/file.css",
"ranges": [
{
"start": 1,
"rule": "color-named"
}
]
}
],
"maxWarningsExceeded": {
// Present if stylelint was configured with a `maxWarnings` count
"maxWarnings": 10,
Expand Down
4 changes: 3 additions & 1 deletion docs/user-guide/configure.md
Expand Up @@ -137,7 +137,7 @@ Reporters may use these severity levels to display violations or exit the proces

### `reportDisables`

You can set the `reportDisables` secondary option to report any disable comments for this rule, effectively disallowing authors to opt out of it.
You can set the `reportDisables` secondary option to report any `stylelint-disable` comments for this rule, effectively disallowing authors to opt out of it.

For example:

Expand All @@ -155,6 +155,8 @@ For example:
}
```

The report is considered to be a lint error.

## `defaultSeverity`

You can set the default severity level for all rules that do not have a severity specified in their secondary options. For example, you can set the default severity to `"warning"`:
Expand Down
2 changes: 2 additions & 0 deletions docs/user-guide/rules/list.md
Expand Up @@ -209,6 +209,7 @@ Grouped first by the following categories and then by the [_thing_](http://apps.
- [`media-feature-name-disallowed-list`](../../../lib/rules/media-feature-name-disallowed-list/README.md): Specify a list of disallowed media feature names.
- [`media-feature-name-no-vendor-prefix`](../../../lib/rules/media-feature-name-no-vendor-prefix/README.md): Disallow vendor prefixes for media feature names (Autofixable).
- [`media-feature-name-value-allowed-list`](../../../lib/rules/media-feature-name-value-allowed-list/README.md): Specify a list of allowed media feature name and value pairs.
- [`media-feature-name-value-whitelist`](../../../lib/rules/media-feature-name-value-whitelist/README.md): Specify a list of allowed media feature name and value pairs. **(deprecated)**
- [`media-feature-name-whitelist`](../../../lib/rules/media-feature-name-whitelist/README.md): Specify a list of allowed media feature names. **(deprecated)**

### Custom media
Expand All @@ -227,6 +228,7 @@ Grouped first by the following categories and then by the [_thing_](http://apps.

### Comment

- [`comment-pattern`](../../../lib/rules/comment-pattern/README.md): Specify a pattern for comments.
- [`comment-word-blacklist`](../../../lib/rules/comment-word-blacklist/README.md): Specify a list of disallowed words within comments. **(deprecated)**
- [`comment-word-disallowed-list`](../../../lib/rules/comment-word-disallowed-list/README.md): Specify a list of disallowed words within comments.

Expand Down
8 changes: 8 additions & 0 deletions docs/user-guide/usage/cli.md
Expand Up @@ -114,6 +114,14 @@ Recursively linting all `.css` files in the `foo` directory using a custom synta
stylelint "foo/**/*.css" --customSyntax path/to/my-custom-syntax.js
```

### Example I - print on success

Ensure output on successful runs:

```shell
stylelint -f verbose "foo/**/*.css"
```

## Exit codes

The CLI can exit the process with the following exit codes:
Expand Down
8 changes: 0 additions & 8 deletions docs/user-guide/usage/node-api.md
Expand Up @@ -66,14 +66,6 @@ An array containing all the stylelint result objects (the objects that formatter

An object containing the maximum number of warnings and the amount found, e.g. `{ maxWarnings: 0, foundWarnings: 12 }`.

### `needlessDisables`

An array of objects, one for each source, with tells you which stylelint-disable comments are not blocking a lint violation

### `invalidScopeDisables`

An array of objects, one for each source, with tells you which rule in `stylelint-disable <rule>` comment don't exist within the configuration object.

## Syntax errors

`stylelint.lint()` does not reject the Promise when your CSS contains syntax errors.
Expand Down
47 changes: 43 additions & 4 deletions docs/user-guide/usage/options.md
Expand Up @@ -141,23 +141,62 @@ You can use this option to see what your linting results would be like without t

CLI flags: `--report-needless-disables, --rd`

Produce a report to clean up your codebase, keeping only the stylelint-disable comments that serve a purpose.
Produce a report to clean up your codebase, keeping only the `stylelint-disable` comments that serve a purpose.

If needless disables are found, the:

- CLI process exits with code `2`
- Node.js API adds a [`needlessDisables`](node-api.md#needlessdisables) property to the returned data
- Node.js API adds errors to the returned data

## `reportInvalidScopeDisables`

CLI flags: `--report-invalid-scope-disables, --risd`

Produce a report of the stylelint-disable comments that used for rules that don't exist within the configuration object.
Produce a report of the `stylelint-disable` comments that used for rules that don't exist within the configuration object.

If invalid scope disables are found, the:

- CLI process exits with code `2`
- Node.js API adds a [`invalidScopeDisables`](node-api.md#invalidscopedisables) property to the returned data
- Node.js API adds errors to the returned data

## `reportDescriptionlessDisables`

CLI flags: `--report-descriptionless-disables, --rdd`

Produce a report of the `stylelint-disable` comments without a description.

For example, when the configuration `{ block-no-empty: true }` is given, the following patterns are reported:

<!-- prettier-ignore -->
```css
/* stylelint-disable */
a {}
```

<!-- prettier-ignore -->
```css
/* stylelint-disable-next-line block-no-empty */
a {}
```

But, the following patterns (`stylelint-disable -- <description>`) are _not_ reported:

<!-- prettier-ignore -->
```css
/* stylelint-disable -- This violation is ignorable. */
a {}
```

<!-- prettier-ignore -->
```css
/* stylelint-disable-next-line block-no-empty -- This violation is ignorable. */
a {}
```

If descriptionless disables are found, the:

- CLI process exits with code `2`
- Node.js API adds errors to the returned data

## `codeFilename`

Expand Down
21 changes: 7 additions & 14 deletions lib/__tests__/cli.test.js
Expand Up @@ -232,14 +232,9 @@ describe('CLI', () => {

expect(process.exitCode).toBe(2);

expect(process.stdout.write).toHaveBeenCalledTimes(2);
expect(process.stdout.write).toHaveBeenNthCalledWith(
1,
expect.stringContaining('needless disable: color-named'),
);
expect(process.stdout.write).toHaveBeenNthCalledWith(
2,
expect.stringContaining('Unexpected empty block'),
expect(process.stdout.write).toHaveBeenCalledTimes(1);
expect(process.stdout.write).toHaveBeenCalledWith(
expect.stringMatching(/Needless disable for "color-named".*Unexpected empty block/s),
);
});

Expand All @@ -253,9 +248,8 @@ describe('CLI', () => {
expect(process.exitCode).toBe(2);

expect(process.stdout.write).toHaveBeenCalledTimes(1);
expect(process.stdout.write).toHaveBeenNthCalledWith(
1,
expect.stringContaining('forbidden disable: block-no-empty'),
expect(process.stdout.write).toHaveBeenCalledWith(
expect.stringContaining('Rule "block-no-empty" may not be disabled'),
);
});

Expand All @@ -270,9 +264,8 @@ describe('CLI', () => {
expect(process.exitCode).toBe(2);

expect(process.stdout.write).toHaveBeenCalledTimes(1);
expect(process.stdout.write).toHaveBeenNthCalledWith(
1,
expect.stringContaining('descriptionless disable: block-no-empty'),
expect(process.stdout.write).toHaveBeenCalledWith(
expect.stringContaining('Disable for "block-no-empty" is missing a description'),
);
});

Expand Down
39 changes: 23 additions & 16 deletions lib/__tests__/descriptionlessDisables.test.js
Expand Up @@ -14,7 +14,7 @@ it('descriptionlessDisables', () => {
/* stylelint-enable */
a {
b {} /* stylelint-disable-line block-no-empty -- Description */
}
}
/* stylelint-disable-next-line block-no-empty
* --
* Description */
Expand All @@ -35,27 +35,34 @@ it('descriptionlessDisables', () => {
code: css,
reportDescriptionlessDisables: true,
}).then((linted) => {
const report = linted.descriptionlessDisables;
const results = linted.results;

expect(results).toHaveLength(1);
const warnings = results[0].warnings.filter(
(warning) => warning.rule === '--report-descriptionless-disables',
);

expect(report).toHaveLength(1);
expect(report[0].ranges).toEqual([
expect(warnings).toEqual([
{
start: 12,
end: 14,
rule: 'all',
unusedRule: 'all',
line: 12,
column: 1,
rule: '--report-descriptionless-disables',
severity: 'error',
text: 'Disable for "all" is missing a description',
},
{
start: 16,
end: 16,
rule: 'block-no-empty',
unusedRule: 'block-no-empty',
line: 16,
column: 8,
rule: '--report-descriptionless-disables',
severity: 'error',
text: 'Disable for "block-no-empty" is missing a description',
},
{
start: 19,
end: 19,
rule: 'block-no-empty',
unusedRule: 'block-no-empty',
line: 18,
column: 1,
rule: '--report-descriptionless-disables',
severity: 'error',
text: 'Disable for "block-no-empty" is missing a description',
},
]);
});
Expand Down

0 comments on commit d9f9b80

Please sign in to comment.