Skip to content

Commit

Permalink
docs: add typescript template (#17500)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Zamiell and nzakas authored Sep 1, 2023
1 parent cd7da5c commit 032c4b1
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 6 deletions.
21 changes: 19 additions & 2 deletions docs/src/_includes/layouts/doc.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
{% set added_version = rule_versions.added[title] %}
{% set removed_version = rule_versions.removed[title] %}

{% if handled_by_typescript %}
{% set handled_by_typescript_content %}
<h2 id="handled_by_typescript">Handled by TypeScript</h2>
<p>
It is safe to disable this rule when using TypeScript because TypeScript's compiler enforces this check.
</p>
{% if extra_typescript_info %}
<p>
{{ extra_typescript_info | markdown | safe }}
</p>
{% endif %}
{% endset %}

{% set all_content = [all_content, handled_by_typescript_content] | join %}
{% endif %}

{% if related_rules %}
{% set related_rules_content %}
<h2 id="related-rules">Related Rules</h2>
Expand Down Expand Up @@ -48,7 +64,7 @@ <h2 id="further-reading">Further Reading</h2>

{% set all_content = [all_content, further_reading_content] | join %}
{% endif %}

{% if rule_meta %}
{% set resources_content %}
<h2 id="resources">Resources</h2>
Expand Down Expand Up @@ -76,7 +92,7 @@ <h1>{{ title }}</h1>
{% endif %}

{% include 'components/docs-toc.html' %}

{{ all_content | safe }}
</div>

Expand All @@ -102,6 +118,7 @@ <h1>{{ title }}</h1>
{% include "partials/docs-footer.html" %}
</div>
</div>

<a id="scroll-up-btn" href="#site_top">
<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>
</a>
Expand Down
3 changes: 1 addition & 2 deletions docs/src/rules/constructor-super.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: constructor-super
rule_type: problem
handled_by_typescript: true
---

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

If you don't want to be notified about invalid/missing `super()` callings in constructors, you can safely disable this rule.

It is safe to disable this rule when using TypeScript because TypeScript's compiler enforces this check (`ts(2335) & ts(2377)`).
1 change: 1 addition & 0 deletions docs/src/rules/getter-return.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: getter-return
rule_type: problem
handled_by_typescript: true
further_reading:
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get
- https://leanpub.com/understandinges6/read/#leanpub-auto-accessor-properties
Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-const-assign.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-const-assign
rule_type: problem
handled_by_typescript: true
---


Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-dupe-args.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-dupe-args
rule_type: problem
handled_by_typescript: true
---


Expand Down
3 changes: 1 addition & 2 deletions docs/src/rules/no-dupe-class-members.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-dupe-class-members
rule_type: problem
handled_by_typescript: true
---


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

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.

It is safe to disable this rule when using TypeScript because TypeScript's compiler enforces this check (`ts(2300) & ts(2393)`).
1 change: 1 addition & 0 deletions docs/src/rules/no-dupe-keys.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-dupe-keys
rule_type: problem
handled_by_typescript: true
---


Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-func-assign.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-func-assign
rule_type: problem
handled_by_typescript: true
---


Expand Down
2 changes: 2 additions & 0 deletions docs/src/rules/no-import-assign.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: no-import-assign
rule_type: problem
handled_by_typescript: true
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.
---


Expand Down
2 changes: 2 additions & 0 deletions docs/src/rules/no-invalid-this.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: no-invalid-this
rule_type: suggestion
handled_by_typescript: true
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.
---


Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-new-symbol.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-new-symbol
rule_type: problem
handled_by_typescript: true
further_reading:
- https://www.ecma-international.org/ecma-262/6.0/#sec-symbol-objects
---
Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-obj-calls.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-obj-calls
rule_type: problem
handled_by_typescript: true
further_reading:
- https://es5.github.io/#x15.8
---
Expand Down
2 changes: 2 additions & 0 deletions docs/src/rules/no-redeclare.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: no-redeclare
rule_type: suggestion
handled_by_typescript: true
extra_typescript_info: Note that while TypeScript will catch `let` redeclares and `const` redeclares, it will not catch `var` redeclares. Thus, if you use the legacy `var` keyword in your TypeScript codebase, this rule will still provide some value.
related_rules:
- no-shadow
---
Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-setter-return.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-setter-return
rule_type: problem
handled_by_typescript: true
related_rules:
- getter-return
further_reading:
Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-this-before-super.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-this-before-super
rule_type: problem
handled_by_typescript: true
---


Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-undef.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-undef
rule_type: problem
handled_by_typescript: true
related_rules:
- no-global-assign
- no-redeclare
Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-unreachable.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-unreachable
rule_type: problem
handled_by_typescript: true
---


Expand Down
1 change: 1 addition & 0 deletions docs/src/rules/no-unsafe-negation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: no-unsafe-negation
rule_type: problem
handled_by_typescript: true
---


Expand Down

0 comments on commit 032c4b1

Please sign in to comment.