@planningcenter/eslint-plugin-tapestry
v1.1.1
Published
ESLint plugin for Tapestry React components
Downloads
23,514
Readme
eslint-plugin-tapestry
ESLint plugin for Tapestry components to encourage best practices and accessibility.
This plugin only tests components provided by Tapestry; it will ignore native HTML elements, Tapestry-React, etc.
Installation
yarn add @planningcenter/eslint-plugin-tapestry --devConfiguration
Recommended Configuration
Flat Config
import tapestry from "@planningcenter/eslint-plugin-tapestry"
export default [tapestry.configs.recommended]Legacy Config
"plugins": [
"tapestry"
],
...
{
"extends": ["plugin:tapestry/recommended"]
}ESLint Flat Config (eslint.config.js)
import tapestry from "@planningcenter/eslint-plugin-tapestry"
export default [
{
plugins: {
tapestry,
},
rules: {
"tapestry/valid-href": "error",
},
},
]Legacy Config (.eslintrc.json)
{
"plugins": ["tapestry"],
"rules": {
"tapestry/valid-href": "error"
}
}Rules
| Rule | Category | Description |
| -------------------------------------- | ------------- | ----------------------------------------------------------------------------------- |
| valid-href | Accessibility | Ensures that BaseLink, Link, and IconLink components have valid href values |
Development
yarn test # Run tests
yarn test --watch # Run tests in watch modeSetup for initial release testing
Tapestry
- Open a terminal to this repo and run
yarn && yalc publish - Open a new terminal to Tapestry and create a temp test branch from
main - Run
yalc add @planningcenter/[email protected] --dev - In
eslint.config.mjs, add or modify
import tapestry from "@planningcenter/eslint-plugin-tapestry"plugins: {tapestry}rules: {"tapestry/valid-href": "error"}
- Restart the ESLint server (
cmd+shift+P>ESLint: Restart Eslint Server) - Open
packages/tapestry/src/components/link/index.stories.tsxand notice that thetapestry-reactLinkisn't reporting any lint errors (no red squiggle lines) - Comment out the
Linkimport and add a line toimport { Link } from "@planningcenter/tapestry"- You should get red squiggle lines on the
Link - Test out different variations of
hrefto see the lint errors
- You should get red squiggle lines on the
- In your terminal, run
yarn lint, notice you'll seetapestry/valid-hreferrors
Groups
- Open a terminal to this repo and run
yarn && yalc publish - Open a new terminal to Groups and create a temp test branch from
main - Run
yalc add @planningcenter/[email protected] --dev - In
eslint.config.mjs, add or modify
import tapestry from "@planningcenter/eslint-plugin-tapestry"plugins: {tapestry}rules: {"tapestry/valid-href": "error"}files: ["**/*.ts", "**/*.tsx", "**/*.jsx", "**/*.js"],
- Restart the ESLint server (
cmd+shift+P>ESLint: Restart Eslint Server) - Open
app/javascript/staff_only/staff_only_nav_links.tsxand notice that thetapestry-reactLinkisn't reporting any lint errors (no red squiggle lines) - Comment out the
Linkimport and add a line toimport { Link } from "@planningcenter/tapestry"- You should get red squiggle lines on the
Link - Test out different variations of
hrefto see the lint errors
- You should get red squiggle lines on the
- In your terminal, run
yarn lint, notice you'll seetapestry/valid-hreferrors
