Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions crates/oxc_linter/src/rules/eslint/no_useless_constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,24 @@ declare_oxc_lint!(
/// simply delegates into its parent class.
///
/// ::: warning
/// Caveat: This lint rule will report on constructors whose sole purpose is to change visibility of a parent constructor.
/// This is because the rule does not have type information to determine if the parent constructor is public, protected, or private.
/// Caveat: This lint rule will report on constructors whose sole purpose
/// is to change visibility of a parent constructor. This is because the rule
/// does not have type information to determine if the parent constructor is
/// `public`, `protected`, or `private`.
/// :::
///
/// ### Examples
///
/// Examples of **incorrect** code for this rule:
/// ```javascript
/// class A {
/// constructor () {
/// }
/// constructor() {}
/// }
///
/// class B extends A {
/// constructor (...args) {
/// super(...args);
/// }
/// constructor(...args) {
/// super(...args);
/// }
/// }
/// ```
///
Expand All @@ -78,22 +79,22 @@ declare_oxc_lint!(
/// class A { }
///
/// class B {
/// constructor () {
/// doSomething();
/// }
/// constructor() {
/// doSomething();
/// }
/// }
///
/// class C extends A {
/// constructor() {
/// super('foo');
/// }
/// constructor() {
/// super('foo');
/// }
/// }
///
/// class D extends A {
/// constructor() {
/// super();
/// doSomething();
/// }
/// constructor() {
/// super();
/// doSomething();
/// }
/// }
/// ```
NoUselessConstructor,
Expand Down
23 changes: 12 additions & 11 deletions crates/oxc_linter/src/rules/vitest/hoisted_apis_on_top.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use crate::{
};

fn hoisted_apis_on_top_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Hoisted API can not be used in a runtime location in this file.")
.with_help("Move this hoisted API to the top of the file to better reflect its behavior.\nIf it's possible replace `vi.mock()` with `vi.doMock`, which is not hoisted.")
OxcDiagnostic::warn("Hoisted API cannot be used in a runtime location in this file.")
.with_help("Move this hoisted API to the top of the file to better reflect its behavior.\nIf possible, replace `vi.mock()` with `vi.doMock`, which is not hoisted.")
.with_label(span)
}

Expand All @@ -39,43 +39,46 @@ declare_oxc_lint!(
/// Examples of **incorrect** code for this rule:
/// ```js
/// if (condition) {
/// vi.mock('some-module', () => {})
/// vi.mock('some-module', () => {})
/// }
/// ```
///
/// ```js
/// if (condition) {
/// vi.unmock('some-module', () => {})
/// vi.unmock('some-module', () => {})
/// }
/// ```
///
/// ```js
/// if (condition) {
/// vi.hoisted(() => {})
/// vi.hoisted(() => {})
/// }
/// ```
///
/// ```js
/// describe('suite', () => {
/// it('test', async () => {
/// vi.mock('some-module', () => {})
/// it('test', async () => {
/// vi.mock('some-module', () => {})
///
/// const sm = await import('some-module')
/// const sm = await import('some-module')
///
/// })
/// })
/// ```
///
/// Examples of **correct** code for this rule:
///
/// ```js
/// if (condition) {
/// vi.doMock('some-module', () => {})
/// vi.doMock('some-module', () => {})
/// }
/// ```
///
/// ```js
/// vi.mock('some-module', () => {})
/// if (condition) {}
/// ```
///
/// ```js
/// vi.unmock('some-module', () => {})
/// if (condition) {}
Expand All @@ -89,14 +92,12 @@ declare_oxc_lint!(
/// ```js
/// vi.mock('some-module', () => {})
///
///
/// describe('suite', () => {
/// it('test', async () => {
/// const sm = await import('some-module')
/// })
/// })
/// ```
///
HoistedApisOnTop,
vitest,
correctness,
Expand Down
20 changes: 10 additions & 10 deletions crates/oxc_linter/src/snapshots/vitest_hoisted_apis_on_top.snap
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
---
source: crates/oxc_linter/src/tester.rs
---
⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API can not be used in a runtime location in this file.
⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API cannot be used in a runtime location in this file.
╭─[hoisted_apis_on_top.tsx:3:6]
2 │ if (foo) {
3 │ vi.mock('foo', () => {});
· ────────────────────────
4 │ }
╰────
help: Move this hoisted API to the top of the file to better reflect its behavior.
If it's possible replace `vi.mock()` with `vi.doMock`, which is not hoisted.
If possible, replace `vi.mock()` with `vi.doMock`, which is not hoisted.

⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API can not be used in a runtime location in this file.
⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API cannot be used in a runtime location in this file.
╭─[hoisted_apis_on_top.tsx:5:6]
4 │ if (foo) {
5 │ vi.hoisted();
· ────────────
6 │ }
╰────
help: Move this hoisted API to the top of the file to better reflect its behavior.
If it's possible replace `vi.mock()` with `vi.doMock`, which is not hoisted.
If possible, replace `vi.mock()` with `vi.doMock`, which is not hoisted.

⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API can not be used in a runtime location in this file.
⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API cannot be used in a runtime location in this file.
╭─[hoisted_apis_on_top.tsx:5:6]
4 │ if (foo) {
5 │ vi.unmock();
· ───────────
6 │ }
╰────
help: Move this hoisted API to the top of the file to better reflect its behavior.
If it's possible replace `vi.mock()` with `vi.doMock`, which is not hoisted.
If possible, replace `vi.mock()` with `vi.doMock`, which is not hoisted.

⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API can not be used in a runtime location in this file.
⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API cannot be used in a runtime location in this file.
╭─[hoisted_apis_on_top.tsx:5:6]
4 │ if (foo) {
5 │ vi.mock();
· ─────────
6 │ }
╰────
help: Move this hoisted API to the top of the file to better reflect its behavior.
If it's possible replace `vi.mock()` with `vi.doMock`, which is not hoisted.
If possible, replace `vi.mock()` with `vi.doMock`, which is not hoisted.

⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API can not be used in a runtime location in this file.
⚠ eslint-plugin-vitest(hoisted-apis-on-top): Hoisted API cannot be used in a runtime location in this file.
╭─[hoisted_apis_on_top.tsx:3:6]
2 │ if (shouldMock) {
3 │ vi.mock(import('something'), () => bar);
· ───────────────────────────────────────
4 │ }
╰────
help: Move this hoisted API to the top of the file to better reflect its behavior.
If it's possible replace `vi.mock()` with `vi.doMock`, which is not hoisted.
If possible, replace `vi.mock()` with `vi.doMock`, which is not hoisted.
Loading