Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(linter): add jsx-a11y settings #1668

Merged
merged 4 commits into from
Dec 16, 2023
Merged

Conversation

msdlisper
Copy link
Contributor

@msdlisper msdlisper commented Dec 13, 2023

When we developed linter for #1141 , we needed to configure some settings for jsx-a11y, which was not supported before, but I am trying to support it now.
like this:

fn config() -> serde_json::Value {
    serde_json::json!([2,{
        "ignoreNonDOM": true
    }])
}

fn settings() -> serde_json::Value {
    serde_json::json!({
        "jsx-a11y": {
            "components": {
                "Button": "button",
            }
        }
    })
}

let pass = vec![
    ("<Button />", Some(config()), Some(settings())),
];

@github-actions github-actions bot added the A-linter Area - Linter label Dec 13, 2023
@Boshen
Copy link
Member

Boshen commented Dec 14, 2023

Thank you for the PR!

We now support reading from eslint config json! This means we can read values off

https://www.npmjs.com/package/eslint-plugin-jsx-a11y#configurations

I think you can read these values into a struct (deserialized) and then add it to LintContext.

@msdlisper
Copy link
Contributor Author

@Boshen I check out the new code just now, let me read the settings from config json.

@msdlisper
Copy link
Contributor Author

@Boshen Done :)

@Boshen Boshen requested a review from camc314 December 15, 2023 03:30
Copy link
Collaborator

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! Thanks!

@Boshen Boshen changed the title feat(linter): add settings for linter feat(linter): add jsx-a11y settings Dec 16, 2023
Copy link
Member

@Boshen Boshen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hashmap can be done with a follow up PR.

crates/oxc_linter/src/lib.rs Show resolved Hide resolved
@Boshen Boshen merged commit 6a90cd4 into oxc-project:main Dec 16, 2023
17 checks passed
IWANABETHATGUY pushed a commit that referenced this pull request Dec 17, 2023
camc314 pushed a commit that referenced this pull request Dec 26, 2023
Added support for component settings for eslint-plugin-jsx-a11y
no-distracting-elements rule based on
#1668 PR.
Updated the test cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants