eslint / json

JSON language plugin for ESLint
Apache License 2.0
18 stars 2 forks source link

feat: Add support for config comments #27

Closed mdjermanovic closed 2 days ago

mdjermanovic commented 4 days ago

Prerequisites checklist

What is the purpose of this pull request?

Adds support for rule configuration comments and disable directives.

What changes did you make? (Give an overview)

Added getInlineConfigNodes(), getDisableDirectives() and applyInlineConfig() methods to the JSONSourceCode class.

Related Issues

Fixes #21

Is there anything you'd like reviewers to focus on?

Unlike the JS language implementation (SourceCode in eslint/eslint), in this implementation rule configs, eslint-disable and eslint-enable can be Line comments. We wanted to implemented this in the JS language as well (https://github.com/eslint/rfcs/pull/34), and eventually did but reverted the change due to backwards compatibility reasons (https://github.com/eslint/eslint/issues/14960). Since there were no backwards compatibility concerns here, it seemed fine to allow this, but let me know if it would be better to have the same behavior as in the JS language (e.g., ignore comments like // eslint rule).