Skip to content

Commit f029090

Browse files
committed
docs(linter): update rule documentation (#7684)
1 parent be9863a commit f029090

4 files changed

Lines changed: 34 additions & 9 deletions

File tree

crates/oxc_linter/src/rules/jest/valid_expect.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,29 @@ impl Default for ValidExpectConfig {
5656
declare_oxc_lint!(
5757
/// ### What it does
5858
///
59-
/// This rule triggers a warning if `expect()` is called with more than one argument
60-
/// or without arguments. It would also issue a warning if there is nothing called
61-
/// on `expect()`, e.g.:
59+
/// Checks that `expect()` is called correctly.
60+
///
61+
/// Why is this bad?
62+
///
63+
/// `expect()` is a function that is used to assert values in tests. It should be called with a single argument, which is the value to be tested. If you call `expect()` with no arguments, or with more than one argument, it will not work as expected.
6264
///
6365
/// ### Example
66+
///
67+
/// Examples of **incorrect** code for this rule:
6468
/// ```javascript
6569
/// expect();
6670
/// expect('something');
6771
/// expect(true).toBeDefined;
6872
/// expect(Promise.resolve('Hi!')).resolves.toBe('Hi!');
6973
/// ```
7074
///
75+
/// Examples of **correct** code for this rule:
76+
/// ```javascript
77+
/// expect('something').toEqual('something');
78+
/// expect(true).toBeDefined();
79+
/// expect(Promise.resolve('Hi!')).resolves.toBe('Hi!');
80+
/// ```
81+
///
7182
/// This rule is compatible with [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest/blob/v1.1.9/docs/rules/valid-expect.md),
7283
/// to use it, add the following configuration to your `.eslintrc.json`:
7384
///

crates/oxc_linter/src/rules/jest/valid_title.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,21 @@ impl std::ops::Deref for ValidTitle {
4444
declare_oxc_lint!(
4545
/// ### What it does
4646
///
47-
/// Checks that the title of Jest blocks are valid by ensuring that titles are:
47+
/// Checks that the titles of Jest blocks are valid.
4848
///
49+
/// Titles must be:
4950
/// - not empty,
50-
/// - is a string,
51+
/// - strings,
5152
/// - not prefixed with their block name,
52-
/// - have no leading or trailing spaces
53+
/// - have no leading or trailing spaces.
54+
///
55+
/// Why is this bad?
56+
///
57+
/// Titles that are not valid can be misleading and make it harder to understand the purpose of the test.
5358
///
5459
/// ### Example
60+
///
61+
/// Examples of **incorrect** code for this rule:
5562
/// ```javascript
5663
/// describe('', () => {});
5764
/// describe('foo', () => {
@@ -63,6 +70,11 @@ declare_oxc_lint!(
6370
/// xit('', () => {});
6471
/// xtest('', () => {});
6572
/// ```
73+
/// Examples of **correct** code for this rule:
74+
/// ```javascript
75+
/// describe('foo', () => {});
76+
/// it('bar', () => {});
77+
/// test('baz', () => {});
6678
ValidTitle,
6779
correctness,
6880
conditional_fix

crates/oxc_linter/src/rules/jsx_a11y/iframe_has_title.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare_oxc_lint!(
2727
///
2828
/// Enforce iframe elements have a title attribute.
2929
///
30-
/// ### Why is this necessary?
30+
/// ### Why is this bad?
3131
///
3232
/// Screen reader users rely on a iframe title to describe the contents of the iframe.
3333
/// Navigating through iframe and iframe elements quickly becomes difficult and confusing for users of this technology if the markup does not contain a title attribute.

crates/oxc_linter/src/rules/react/no_children_prop.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ pub struct NoChildrenProp;
2525
declare_oxc_lint!(
2626
/// ### What it does
2727
///
28-
/// Children should always be actual children, not passed in as a prop.
28+
/// Checks that children are not passed using a prop.
2929
///
30-
/// When using JSX, the children should be nested between the opening and closing tags.
30+
/// Why is this bad?
3131
///
32+
/// Children should always be actual children, not passed in as a prop.
33+
/// When using JSX, the children should be nested between the opening and closing tags.
3234
/// When not using JSX, the children should be passed as additional arguments to `React.createElement`.
3335
///
3436
/// ### Example

0 commit comments

Comments
 (0)