Skip to content

Commit 032c4b1

Browse files
Zamiellnzakas
andauthored
docs: add typescript template (#17500)
* docs: add typescript template * fix: formatting * chore: update docs with AndreaPontrandolfo's findings * Update no-import-assign.md * chore: update no-redeclare * fix: update TS code numbers * feat: cleanup typescript error codes * Update docs/src/_includes/layouts/doc.html Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> * Update docs/src/rules/no-redeclare.md Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> * Update docs/src/rules/no-import-assign.md Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> * Update docs/src/rules/no-invalid-this.md Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com> * fix: formatting error --------- Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
1 parent cd7da5c commit 032c4b1

18 files changed

+39
-6
lines changed

docs/src/_includes/layouts/doc.html

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@
1919
{% set added_version = rule_versions.added[title] %}
2020
{% set removed_version = rule_versions.removed[title] %}
2121

22+
{% if handled_by_typescript %}
23+
{% set handled_by_typescript_content %}
24+
<h2 id="handled_by_typescript">Handled by TypeScript</h2>
25+
<p>
26+
It is safe to disable this rule when using TypeScript because TypeScript's compiler enforces this check.
27+
</p>
28+
{% if extra_typescript_info %}
29+
<p>
30+
{{ extra_typescript_info | markdown | safe }}
31+
</p>
32+
{% endif %}
33+
{% endset %}
34+
35+
{% set all_content = [all_content, handled_by_typescript_content] | join %}
36+
{% endif %}
37+
2238
{% if related_rules %}
2339
{% set related_rules_content %}
2440
<h2 id="related-rules">Related Rules</h2>
@@ -48,7 +64,7 @@ <h2 id="further-reading">Further Reading</h2>
4864

4965
{% set all_content = [all_content, further_reading_content] | join %}
5066
{% endif %}
51-
67+
5268
{% if rule_meta %}
5369
{% set resources_content %}
5470
<h2 id="resources">Resources</h2>
@@ -76,7 +92,7 @@ <h1>{{ title }}</h1>
7692
{% endif %}
7793

7894
{% include 'components/docs-toc.html' %}
79-
95+
8096
{{ all_content | safe }}
8197
</div>
8298

@@ -102,6 +118,7 @@ <h1>{{ title }}</h1>
102118
{% include "partials/docs-footer.html" %}
103119
</div>
104120
</div>
121+
105122
<a id="scroll-up-btn" href="#site_top">
106123
<svg fill="none" height="24" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" width="24"><line x1="12" x2="12" y1="19" y2="5"/><polyline points="5 12 12 5 19 12"/></svg>
107124
</a>

docs/src/rules/constructor-super.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: constructor-super
33
rule_type: problem
4+
handled_by_typescript: true
45
---
56

67
Constructors of derived classes must call `super()`.
@@ -69,5 +70,3 @@ class A extends B {
6970
## When Not To Use It
7071

7172
If you don't want to be notified about invalid/missing `super()` callings in constructors, you can safely disable this rule.
72-
73-
It is safe to disable this rule when using TypeScript because TypeScript's compiler enforces this check (`ts(2335) & ts(2377)`).

docs/src/rules/getter-return.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: getter-return
33
rule_type: problem
4+
handled_by_typescript: true
45
further_reading:
56
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get
67
- https://leanpub.com/understandinges6/read/#leanpub-auto-accessor-properties

docs/src/rules/no-const-assign.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: no-const-assign
33
rule_type: problem
4+
handled_by_typescript: true
45
---
56

67

docs/src/rules/no-dupe-args.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: no-dupe-args
33
rule_type: problem
4+
handled_by_typescript: true
45
---
56

67

docs/src/rules/no-dupe-class-members.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: no-dupe-class-members
33
rule_type: problem
4+
handled_by_typescript: true
45
---
56

67

@@ -101,5 +102,3 @@ class Foo {
101102
This rule should not be used in ES3/5 environments.
102103

103104
In ES2015 (ES6) or later, if you don't want to be notified about duplicate names in class members, you can safely disable this rule.
104-
105-
It is safe to disable this rule when using TypeScript because TypeScript's compiler enforces this check (`ts(2300) & ts(2393)`).

docs/src/rules/no-dupe-keys.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: no-dupe-keys
33
rule_type: problem
4+
handled_by_typescript: true
45
---
56

67

docs/src/rules/no-func-assign.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: no-func-assign
33
rule_type: problem
4+
handled_by_typescript: true
45
---
56

67

docs/src/rules/no-import-assign.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: no-import-assign
33
rule_type: problem
4+
handled_by_typescript: true
5+
extra_typescript_info: Note that the compiler will not catch the `Object.assign()` case. Thus, if you use `Object.assign()` in your codebase, this rule will still provide some value.
46
---
57

68

docs/src/rules/no-invalid-this.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: no-invalid-this
33
rule_type: suggestion
4+
handled_by_typescript: true
5+
extra_typescript_info: Note that, technically, TypeScript will only catch this if you have the `strict` or `noImplicitThis` flags enabled. These are enabled in most TypeScript projects, since they are considered to be best practice.
46
---
57

68

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy