fix(linter/consistent-function-scoping): allow functions passed as arguments (#5011)

This commit is contained in:
Don Isaac 2024-08-20 17:00:50 -04:00 committed by GitHub
parent 4425b177d4
commit c43945c808
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 760 additions and 1061 deletions

View file

@ -2,218 +2,202 @@
source: crates/oxc_linter/src/tester.rs
---
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:4:26]
3 │ {
4 │ function doBar(bar) {
╭─[consistent_function_scoping.tsx:4:34]
3 │ {
4 │ function doBar(bar) {
· ─────
5 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:30]
2 │ function doFoo(FooComponent) {
3 │ function Bar() {
· ───
4 │ return <FooComponent />;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:30]
2 │ function Foo() {
3 │ function Bar () {
· ───
4 │ return <div />
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:30]
2 │ function foo() {
3 │ function bar() {
· ───
4 │ return <JSX/>;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:27]
2 │ function doFoo(Foo) {
3 │ const doBar = () => arguments;
· ─────
4 │ return doBar();
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:30]
2 │ function doFoo(foo) {
3 │ function doBar(bar) {
· ─────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:4:30]
3 │ const foo = 'foo';
4 │ function doBar(bar) {
· ─────
5 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:1:29]
1 │ function doFoo() { function doBar(bar) { return bar; } }
· ─────
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:1:37]
1 │ const doFoo = function() { function doBar(bar) { return bar; } };
· ─────
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:35]
2 │ const doFoo = function() {
3 │ const doBar = function(bar) {
· ────────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:1:34]
1 │ function doFoo() { const doBar = function(bar) { return bar; }; }
· ────────
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:1:34]
1 │ function doFoo() { const doBar = function(bar) { return bar; }; doBar(); }
· ────────
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:1:29]
1 │ const doFoo = () => { const doBar = bar => { return bar; } }
· ─────
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:30]
2 │ function doFoo(Foo) {
3 │ function doBar() {
· ─────
4 │ return this;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:1:29]
1 │ function doFoo(Foo) { const doBar = () => (function() {return this})(); return doBar(); };
· ─────
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:27]
2 │ function doFoo(Foo) {
3 │ const doBar = () => (function() {return () => this})();
· ─────
4 │ return doBar();
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:30]
2 │ function doFoo(Foo) {
3 │ function doBar() {
· ─────
4 │ return arguments;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:27]
2 │ function doFoo(Foo) {
3 │ const doBar = () => (function() {return arguments})();
· ─────
4 │ return doBar();
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:30]
2 │ function doFoo(foo) {
3 │ function doBar(bar) {
· ─────
4 │ return doBar(bar);
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:30]
2 │ function doFoo(foo) {
3 │ function doBar(bar) {
· ─────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:1:29]
1 │ function doFoo() { function doBar() {} }
· ─────
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:5:38]
4 │ {
5 │ function doBar(bar) {
· ─────
6 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:4:34]
3 │ {
4 │ function doBar(bar) {
· ─────
5 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:1:46]
1 │ for (let foo = 0; foo < 1; foo++) { function doBar(bar) { return bar; } }
· ─────
5 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:23]
2 │ function doFoo(FooComponent) {
3 │ function Bar() {
· ───
4 │ return <FooComponent />;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:23]
2 │ function Foo() {
3 │ function Bar () {
· ───
4 │ return <div />
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:23]
2 │ function foo() {
3 │ function bar() {
· ───
4 │ return <JSX/>;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:20]
2 │ function doFoo(Foo) {
3 │ const doBar = () => arguments;
· ─────
4 │ return doBar();
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ function doFoo(foo) {
3 │ function doBar(bar) {
· ─────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:4:18]
3 │ const foo = 'foo';
4 │ function doBar(bar) {
· ─────
5 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ function doFoo() {
3 │ function doBar(bar) {
· ─────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ const doFoo = function() {
3 │ function doBar(bar) {
· ─────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:23]
2 │ const doFoo = function() {
3 │ const doBar = function(bar) {
· ────────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:23]
2 │ function doFoo() {
3 │ const doBar = function(bar) {
· ────────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:23]
2 │ function doFoo() {
3 │ const doBar = function(bar) {
· ────────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:15]
2 │ const doFoo = () => {
3 │ const doBar = bar => {
· ─────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ function doFoo(Foo) {
3 │ function doBar() {
· ─────
4 │ return this;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:15]
2 │ function doFoo(Foo) {
3 │ const doBar = () => (function() {return this})();
· ─────
4 │ return doBar();
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:15]
2 │ function doFoo(Foo) {
3 │ const doBar = () => (function() {return () => this})();
· ─────
4 │ return doBar();
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ function doFoo(Foo) {
3 │ function doBar() {
· ─────
4 │ return arguments;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:15]
2 │ function doFoo(Foo) {
3 │ const doBar = () => (function() {return arguments})();
· ─────
4 │ return doBar();
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:24]
2 │ function doFoo(foo) {
3 │ function doBar(bar) {
· ─────
4 │ return doBar(bar);
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ function doFoo(foo) {
3 │ function doBar(bar) {
· ─────
4 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ function doFoo() {
3 │ function doBar() {}
· ─────
4 │ }
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:5:20]
4 │ {
5 │ function doBar(bar) {
· ─────
6 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:4:19]
3 │ {
4 │ function doBar(bar) {
· ─────
5 │ return bar;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ for (let foo = 0; foo < 1; foo++) {
3 │ function doBar(bar) {
· ─────
4 │ return bar;
╰────
help: Move this function to the outer scope.
@ -267,172 +251,158 @@ source: crates/oxc_linter/src/tester.rs
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:4:19]
3 │ function foo() {
4 │ function bar() {
· ───
5 │ }
╭─[consistent_function_scoping.tsx:4:34]
3 │ function foo() {
4 │ function bar() {
· ───
5 │ }
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:4:19]
3 │ function foo() {
4 │ function bar() {
· ───
5 │ }
╭─[consistent_function_scoping.tsx:4:34]
3 │ function foo() {
4 │ function bar() {
· ───
5 │ }
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ process.nextTick(() => {
3 │ function returnsZero() {
· ───────────
4 │ return true;
╭─[consistent_function_scoping.tsx:3:30]
2 │ process.nextTick(() => {
3 │ function returnsZero() {
· ───────────
4 │ return true;
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:5:19]
4 │ function() {
5 │ function bar() {
· ───
6 │ }
╭─[consistent_function_scoping.tsx:5:34]
4 │ function() {
5 │ function bar() {
· ───
6 │ }
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:9:19]
8 │ function() {
9 │ function baz() {
· ───
10 │ }
╭─[consistent_function_scoping.tsx:9:34]
8 │ function() {
9 │ function baz() {
· ───
10 │ }
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:4:18]
3 │ const Bar = <div />
4 │ function doBaz() {
· ─────
5 │ return 42
╭─[consistent_function_scoping.tsx:4:30]
3 │ const Bar = <div />
4 │ function doBaz() {
· ─────
5 │ return 42
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ function Foo() {
3 │ function Bar () {
· ───
4 │ return <div />
╭─[consistent_function_scoping.tsx:3:30]
2 │ function Foo() {
3 │ function Bar () {
· ───
4 │ return <div />
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:6:18]
5 │ }
6 │ function doBaz() {
· ─────
7 │ return 42
╭─[consistent_function_scoping.tsx:6:30]
5 │ }
6 │ function doBaz() {
· ─────
7 │ return 42
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:6:18]
5 │ }
6 │ function b() {}
·
7 │ function c() {}
╭─[consistent_function_scoping.tsx:6:30]
5 │ }
6 │ function b() {}
· ─
7 │ function c() {}
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:7:18]
6 │ function b() {}
7 │ function c() {}
·
8 │ }
╭─[consistent_function_scoping.tsx:7:30]
6 │ function b() {}
7 │ function c() {}
· ─
8 │ }
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:10:18]
9 │ function fn2() {
10 │ function foo() {}
· ───
11 │ }
╭─[consistent_function_scoping.tsx:10:30]
9 │ function fn2() {
10 │ function foo() {}
· ───
11 │ }
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:18]
2 │ const outer = () => {
3 │ function inner() {}
· ─────
4 │ }
╭─[consistent_function_scoping.tsx:1:32]
1 │ const outer = () => { function inner() {} }
· ─────
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:17]
2 │ function foo() {
3 │ function bar() {}
· ───
4 │ }
╭─[consistent_function_scoping.tsx:1:27]
1 │ function foo() { function bar() {} }
· ───
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:23]
2 │ function foo() {
3 │ async function bar() {}
· ───
4 │ }
╭─[consistent_function_scoping.tsx:1:33]
1 │ function foo() { async function bar() {} }
· ───
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:19]
2 │ function foo() {
3 │ function * bar() {}
· ───
4 │ }
╭─[consistent_function_scoping.tsx:1:29]
1 │ function foo() { function * bar() {} }
· ───
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:25]
2 │ function foo() {
3 │ async function * bar() {}
· ───
4 │ }
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:14]
2 │ function foo() {
3 │ const bar = () => {}
╭─[consistent_function_scoping.tsx:1:35]
1 │ function foo() { async function * bar() {} }
· ───
4 │ }
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:14]
2 │ function foo() {
3 │ const bar = async () => {}
· ───
4 │ }
╭─[consistent_function_scoping.tsx:1:24]
1 │ function foo() { const bar = () => {} }
· ───
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:22]
2 │ function doFoo() {
3 │ const doBar = function(bar) {
· ────────
4 │ return bar;
╭─[consistent_function_scoping.tsx:1:24]
1 │ function foo() { const bar = async () => {} }
· ───
╰────
help: Move this function to the outer scope.
⚠ eslint-plugin-unicorn(consistent-function-scoping): Function does not capture any variables from the outer scope.
╭─[consistent_function_scoping.tsx:3:35]
2 │ function doFoo() {
3 │ const doBar = function(bar) {
· ────────
4 │ return bar;
╰────
help: Move this function to the outer scope.