forked from dart-lang/site-www
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement individual linter rule pages (dart-lang#4999)
This PR is meant to finalize work to make dart.dev a satisfactory replacement for [`dart-lang.github.io/linter/`](https://dart-lang.github.io/linter/) while `dart-lang/linter` moves to the SDK and we work on consolidating and improving documentation (dart-lang#4498). It does this by (staged links after colon (`:`)): - Updating the information on dart.dev/lints for the latest state of the linter: [/lints](https://dart-dev--pr4999-feature-linter-indiv-zetj76b0.web.app/tools/linter-rules) - Making dart.dev/lints an index page rather than including all information: [/lints](https://dart-dev--pr4999-feature-linter-indiv-zetj76b0.web.app/tools/linter-rules) - Moving the long-form lint rule documentation to individual pages found at `dart.dev/lints/<rule>`: [/lints/avoid_dynamic_calls](https://dart-dev--pr4999-feature-linter-indiv-zetj76b0.web.app/lints/avoid_dynamic_calls) - It does this by using a Jekyll page generator based on `linter_rules.json`. - Adding a textual reference pointing to the recently released all linter rules page (dart-lang@38973de) found at: [/lints/all](https://dart-dev--pr4999-feature-linter-indiv-zetj76b0.web.app/lints/all) - Updating and links and references for these previous changes (mostly Effective Dart). Contributes to https://github.com/dart-lang/linter/issues/4460, dart-lang#4498, dart-lang#4499 **Note:** This is an intermediate step and doesn't aim to improve the formatting or style of the information on the index or individual pages. That will be part of follow-up work as we work on improvements to the diagnostic linter rule documentation.
- Loading branch information
1 parent
35cebb7
commit a448ff1
Showing
18 changed files
with
201 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{% assign lint = include.lint -%} | ||
|
||
{{lint.description}} | ||
|
||
{% if lint.sinceDartSdk == "Unreleased" %} | ||
_This rule is currently **experimental** | ||
and not yet available in a stable SDK._ | ||
{% elsif lint.state == "removed" %} | ||
_This rule has been removed as of the latest Dart releases._ | ||
{% elsif lint.state != "stable" %} | ||
_This rule is currently **{{lint.state}}** | ||
and available as of Dart {{lint.sinceDartSdk}}._ | ||
{% else %} | ||
_This rule is available as of Dart {{lint.sinceDartSdk}}._ | ||
{% endif %} | ||
|
||
{% if lint.sets != empty %} | ||
|
||
{% assign rule_sets = "" %} | ||
|
||
{% for set in lint.sets %} | ||
|
||
{% if set == "core" or set == "recommended" %} | ||
{% assign set_link = "lints" %} | ||
{% elsif set == "flutter" %} | ||
{% assign set_link = "flutter_lints" %} | ||
{% else %} | ||
{% assign set_link = set %} | ||
{% endif %} | ||
|
||
{%- capture rule_set -%} | ||
[{{set}}](/tools/linter-rules#{{set_link}}){% if forloop.last == false %},{% endif %} | ||
{% endcapture %} | ||
|
||
{%- assign rule_sets = rule_sets | append: rule_set -%} | ||
|
||
{% endfor %} | ||
|
||
<em>Rule sets: {{ rule_sets }}</em> | ||
|
||
{% endif %} | ||
|
||
{% if lint.fixStatus == "hasFix" %} | ||
<em>This rule has a [quick fix](/tools/linter-rules#quick-fixes) available.</em> | ||
{% endif %} | ||
|
||
{% if lint.incompatible != empty %} | ||
|
||
{% assign incompatible_rules = "" %} | ||
|
||
{% for incompatible in lint.incompatible %} | ||
|
||
{%- capture incompatible_rule -%} | ||
[{{incompatible}}](/tools/linter-rules/{{incompatible}}){% if forloop.last == false %},{% endif %} | ||
{% endcapture %} | ||
|
||
{% assign incompatible_rules = incompatible_rules | append: incompatible_rule %} | ||
|
||
{% endfor %} | ||
|
||
<em>Incompatible rules: {{ incompatible_rules }}</em> | ||
|
||
{% endif %} | ||
|
||
## Details | ||
|
||
{{lint.details}} | ||
|
||
## Usage | ||
|
||
To enable the `{{lint.name}}` rule, | ||
add `{{lint.name}}` under **linter > rules** in your | ||
[`analysis_options.yaml`](/guides/language/analysis-options) | ||
file: | ||
|
||
```yaml | ||
linter: | ||
rules: | ||
- {{lint.name}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{:.linter-rule} | ||
{% if include.rule %} | ||
Linter rule: [{{include.rule}}](/tools/linter-rules#{{include.rule}}) | ||
Linter rule: [{{include.rule}}](/tools/linter-rules/{{include.rule}}) | ||
{% else %} | ||
Linter rules: [{{include.rule1}}](/tools/linter-rules#{{include.rule1}}), [{{include.rule2}}](/tools/linter-rules#{{include.rule2}}) | ||
Linter rules: [{{include.rule1}}](/tools/linter-rules/{{include.rule1}}), [{{include.rule2}}](/tools/linter-rules/{{include.rule2}}) | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
layout: default | ||
--- | ||
|
||
{% capture linter-rule %}{% include linter-page-content.md lint=page.lint %}{% endcapture %} | ||
{{ linter-rule | markdownify }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Jekyll | ||
class DiagnosticPageGenerator < Jekyll::Generator | ||
def generate(site) | ||
linter_rules = site.data['linter_rules'] | ||
|
||
linter_rules.each { |lint| | ||
site.pages << LinterPage.new(site, lint) | ||
} | ||
end | ||
end | ||
|
||
class LinterPage < Jekyll::PageWithoutAFile | ||
def initialize(site, lint) | ||
@site = site | ||
@base = site.source | ||
@dir = "/tools/linter-rules" | ||
@basename = lint['name'] | ||
@ext = '.md' | ||
@name = "#{lint['name']}.md" | ||
@content = "" | ||
|
||
@data = { | ||
'title' => basename, | ||
'layout' => 'linter-rule-standalone', | ||
'lint' => lint, | ||
'underscore_breaker_titles' => true | ||
} | ||
|
||
end | ||
end | ||
end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.