From a9de86bdf94fa56915beadb993ad02a240827a7a Mon Sep 17 00:00:00 2001 From: Kate Higa Date: Thu, 21 Jul 2022 12:51:53 -0700 Subject: [PATCH 1/4] Add README --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 6cbac4bc..4a78aa57 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,35 @@ The available configs are: - `typescript` - Useful rules when writing TypeScript. +### Component mapping (Experimental) + +_Note: This is experimental and subject to change._ + +The `react` config includes rules which target specific HTML elements. You may provide a mapping of custom components to an HTML element in your `eslintrc` configuration to increase linter coverage. + +For each component, you may specify a `default` and/or `props`. `default` may make sense if there's a 1:1 mapping between a component and an HTML element. However, if the HTML output of a component is dependent on a prop value, you can provide a mapping using the `props` key. To minimize conflicts and complexity, this currently only supports the mapping of a single prop type. + +```json +{ + "settings": { + "github": { + "components": { + "Box": { "default": "p" }, + "Link": { "props": {"as": { "undefined": "a", "a": "a", "button": "button"}}}, + } + } + } +} +``` + +This config will be interpreted in the following way: + +- All `` elements will be treated as a `p` element type. +- `` without a defined `as` prop will be treated as a `a`. +- `` will treated as an `a` element type. +- `` will be treated as a `button` element type. +- `` will be treated as the original `Link` element type because there is no matching mapping for `as='summary'`. + ### Rules - [Array Foreach](./docs/rules/array-foreach.md) From 344e30b580bd3b5115ad820be51a4170531a637d Mon Sep 17 00:00:00 2001 From: Kate Higa Date: Thu, 21 Jul 2022 15:02:17 -0700 Subject: [PATCH 2/4] Update parser option --- lib/configs/react.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/configs/react.js b/lib/configs/react.js index 5845b799..c76d66d9 100644 --- a/lib/configs/react.js +++ b/lib/configs/react.js @@ -1,6 +1,9 @@ module.exports = { - env: { - browser: true + parserOptions: { + sourceType: 'module', + ecmaFeatures: { + jsx: true + } }, plugins: ['github', 'jsx-a11y'], extends: ['plugin:jsx-a11y/recommended'], From 602d4bc42b42f08736e4c06c9c16fbe76d23ce82 Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Fri, 22 Jul 2022 08:20:34 -0700 Subject: [PATCH 3/4] Update README.md Co-authored-by: Owen Niblock --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a78aa57..25fca7c4 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ This config will be interpreted in the following way: - `` without a defined `as` prop will be treated as a `a`. - `` will treated as an `a` element type. - `` will be treated as a `button` element type. -- `` will be treated as the original `Link` element type because there is no matching mapping for `as='summary'`. +- `` will be treated as the original `Link` element type because there is no matching mapping for `as='summary'` resulting in the element being treated as an `a` ### Rules From 21641297a43e6747d75e0a75c10fcae13654a8b6 Mon Sep 17 00:00:00 2001 From: Kate Higa <16447748+khiga8@users.noreply.github.com> Date: Fri, 22 Jul 2022 08:35:49 -0700 Subject: [PATCH 4/4] Updating for clarity --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25fca7c4..6f53657a 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ This config will be interpreted in the following way: - `` without a defined `as` prop will be treated as a `a`. - `` will treated as an `a` element type. - `` will be treated as a `button` element type. -- `` will be treated as the original `Link` element type because there is no matching mapping for `as='summary'` resulting in the element being treated as an `a` +- `` will be treated as the raw `Link` type because there is no configuration set for `as='summary'`. ### Rules