Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Autogenerated new docs and demo at Fri Mar 25 2022 18:30:15
Browse files Browse the repository at this point in the history
  • Loading branch information
ESLint Jenkins committed Mar 25, 2022
1 parent 4b7637c commit 9e578ca
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 13 deletions.
4 changes: 3 additions & 1 deletion _data/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,9 @@ types:
hasSuggestions: false
name: no-inline-comments
recommended: false
- description: disallow `this` keywords outside of classes or class-like objects
- description: >-
disallow use of `this` in contexts where the value of `this` is
`undefined`
fixable: false
hasSuggestions: false
name: no-invalid-this
Expand Down
42 changes: 42 additions & 0 deletions _posts/2022-03-25-eslint-v8.12.0-released.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
layout: post
title: ESLint v8.12.0 released
teaser: "We just pushed ESLint v8.12.0, which is a minor release upgrade of ESLint. This release adds some new features and fixes several bugs found in the previous release."
image: release-notes-minor.png
categories:
- Release Notes
tags:
- Release
---








## Features


* [`685a67a`](https://github.com/eslint/eslint/commit/685a67a62bdea19ca9ce12008a034b8d31162422) feat: fix logic for top-level `this` in [no-invalid-this](/docs/rules/no-invalid-this) and [no-eval](/docs/rules/no-eval) ([#15712](https://github.com/eslint/eslint/issues/15712)) (Milos Djermanovic)














## Chores


* [`18f5e05`](https://github.com/eslint/eslint/commit/18f5e05bce10503186989d81ca484abb185a2c9d) chore: [padding-line-between-statements](/docs/rules/padding-line-between-statements) remove useless `additionalItems` ([#15706](https://github.com/eslint/eslint/issues/15706)) (Martin Sadovy)


22 changes: 11 additions & 11 deletions docs/rules/no-invalid-this.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ rule_type: suggestion

# no-invalid-this

Disallows `this` keywords outside of classes or class-like objects.
Disallows use of `this` in contexts where the value of `this` is `undefined`.

Under the strict mode, `this` keywords outside of classes or class-like objects might be `undefined` and raise a `TypeError`.

## Rule Details

This rule aims to flag usage of `this` keywords outside of classes or class-like objects.
This rule aims to flag usage of `this` keywords in contexts where the value of `this` is `undefined`.

Basically, this rule checks whether or not a function containing `this` keyword is a constructor or a method.
Top-level `this` in scripts is always considered valid because it refers to the global object regardless of the strict mode.

Top-level `this` in ECMAScript modules is always considered invalid because its value is `undefined`.

For `this` inside functions, this rule basically checks whether or not the function containing `this` keyword is a constructor or a method. Note that arrow functions have lexical `this`, and that therefore this rule checks their enclosing contexts.

This rule judges from following conditions whether or not the function is a constructor:

Expand All @@ -38,6 +42,7 @@ And this rule allows `this` keywords in functions below:

And this rule always allows `this` keywords in the following contexts:

* At the top level of scripts.
* In class field initializers.
* In class static blocks.

Expand All @@ -54,9 +59,6 @@ Examples of **incorrect** code for this rule in strict mode:

"use strict";

this.a = 0;
baz(() => this);

(function() {
this.a = 0;
baz(() => this);
Expand All @@ -77,11 +79,6 @@ foo(function() {
baz(() => this);
});

obj.foo = () => {
// `this` of arrow functions is the outer scope's.
this.a = 0;
};

var obj = {
aaa: function() {
return function foo() {
Expand All @@ -106,6 +103,9 @@ Examples of **correct** code for this rule in strict mode:

"use strict";

this.a = 0;
baz(() => this);

function Foo() {
// OK, this is in a legacy style constructor.
this.a = 0;
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/formatters/html-formatter-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<div id="overview" class="bg-2">
<h1>ESLint Report</h1>
<div>
<span>9 problems (5 errors, 4 warnings)</span> - Generated on Fri Mar 11 2022 17:27:21 GMT-0500 (Eastern Standard Time)
<span>9 problems (5 errors, 4 warnings)</span> - Generated on Fri Mar 25 2022 18:30:14 GMT-0400 (Eastern Daylight Time)
</div>
</div>
<table>
Expand Down

0 comments on commit 9e578ca

Please sign in to comment.