Skip to content

Commit

Permalink
Auto merge of #9616 - unvalley:add-default-to-lint-groups, r=xFrednet
Browse files Browse the repository at this point in the history
Add Default to Clippy Lints Lint groups

- related to #7958

This PR adds a default (reset) button to Clippy Lints Lint groups. (change for website)
[The page](https://rust-lang.github.io/rust-clippy/master/index.html) sets only `Deprecated` to false by default.
Certainly it is easy to set only `deprecated` to false, but it may be a bit lazy for beginners.

https://user-images.githubusercontent.com/38400669/194831117-3ade7e0d-c4de-4189-9daf-3be8ea3cdd18.mov

changelog: none
  • Loading branch information
bors committed Oct 11, 2022
2 parents 8e87d39 + 178799f commit 122ae22
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions util/gh-pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,12 @@ <h1>Clippy Lints</h1>
All
</label>
</li>
<li class="checkbox">
<label ng-click="resetGroupsToDefault()">
<input type="checkbox" class="invisible" />
Default
</label>
</li>
<li class="checkbox">
<label ng-click="toggleGroups(false)">
<input type="checkbox" class="invisible" />
Expand Down
15 changes: 13 additions & 2 deletions util/gh-pages/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
return $scope.levels[lint.level];
};

var GROUPS_FILTER_DEFAULT = {
const GROUPS_FILTER_DEFAULT = {
cargo: true,
complexity: true,
correctness: true,
Expand All @@ -125,8 +125,12 @@
restriction: true,
style: true,
suspicious: true,
}

$scope.groups = {
...GROUPS_FILTER_DEFAULT
};
$scope.groups = GROUPS_FILTER_DEFAULT;

const THEMES_DEFAULT = {
light: "Light",
rust: "Rust",
Expand Down Expand Up @@ -164,6 +168,13 @@
}
};

$scope.resetGroupsToDefault = function () {
const groups = $scope.groups;
for (const [key, value] of Object.entries(GROUPS_FILTER_DEFAULT)) {
groups[key] = value;
}
};

$scope.selectedValuesCount = function (obj) {
return Object.values(obj).filter(x => x).length;
}
Expand Down

0 comments on commit 122ae22

Please sign in to comment.