eslint-plugin-primer-react 7.0.0-rc.515dd2e → 7.0.0-rc.5c89573
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/docs/rules/a11y-no-title-usage.md +40 -0
- package/package-lock.json +92 -64
- package/package.json +3 -3
- package/src/configs/recommended.js +1 -0
- package/src/index.js +1 -0
- package/src/rules/__tests__/a11y-no-title-usage.test.js +27 -0
- package/src/rules/__tests__/a11y-tooltip-interactive-trigger.test.js +16 -0
- package/src/rules/a11y-no-title-usage.js +37 -0
- package/src/rules/a11y-tooltip-interactive-trigger.js +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,12 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
- [#270](https://github.com/primer/eslint-plugin-primer-react/pull/270) [`17814a2`](https://github.com/primer/eslint-plugin-primer-react/commit/17814a2d77d752b6675e51124fe3c18671837a10) Thanks [@broccolinisoup](https://github.com/broccolinisoup)! - Update a11y-use-next-tooltip to be a11y-use-accessible-tooltip and make the changes accordingly
|
|
8
8
|
|
|
9
|
+
- [#316](https://github.com/primer/eslint-plugin-primer-react/pull/316) [`40016c8`](https://github.com/primer/eslint-plugin-primer-react/commit/40016c8db99b4045ed7474cead0b48eed05f5f64) Thanks [@TylerJDev](https://github.com/TylerJDev)! - Add `a11y-no-title-usage` that warns against using `title` in some components
|
|
10
|
+
|
|
9
11
|
### Minor Changes
|
|
10
12
|
|
|
11
13
|
- [#266](https://github.com/primer/eslint-plugin-primer-react/pull/266) [`90134bc`](https://github.com/primer/eslint-plugin-primer-react/commit/90134bcee073c424e81c53e69632e1518798af93) Thanks [@keithamus](https://github.com/keithamus)! - Add enforce-css-module-default-import rule
|
|
12
14
|
|
|
13
15
|
- [#258](https://github.com/primer/eslint-plugin-primer-react/pull/258) [`83f29f3`](https://github.com/primer/eslint-plugin-primer-react/commit/83f29f339999b9c21d95167bcc2680c1797cbab6) Thanks [@keithamus](https://github.com/keithamus)! - Add enforce-css-module-identifier-casing rule
|
|
14
16
|
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#314](https://github.com/primer/eslint-plugin-primer-react/pull/314) [`63ef9fd`](https://github.com/primer/eslint-plugin-primer-react/commit/63ef9fdf02a9c4b80528644a96fd81e366bce187) Thanks [@khiga8](https://github.com/khiga8)! - fix: Link to should be allowed to have tooltip
|
|
20
|
+
|
|
15
21
|
## 6.1.6
|
|
16
22
|
|
|
17
23
|
### Patch Changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
## Rule Details
|
|
2
|
+
|
|
3
|
+
This rule aims to prevent the use of the `title` attribute with some components from `@primer/react`. The `title` attribute is not keyboard accessible, which results in accessibility issues. Instead, we should utilize alternatives that are accessible.
|
|
4
|
+
|
|
5
|
+
👎 Examples of **incorrect** code for this rule
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import {RelativeTime} from '@primer/react'
|
|
9
|
+
|
|
10
|
+
const App = () => <RelativeTime date={new Date('2020-01-01T00:00:00Z')} noTitle={false} />
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
👍 Examples of **correct** code for this rule:
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
import {RelativeTime} from '@primer/react'
|
|
17
|
+
|
|
18
|
+
const App = () => <RelativeTime date={new Date('2020-01-01T00:00:00Z')} />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The noTitle attribute is true by default, so it can be omitted.
|
|
22
|
+
|
|
23
|
+
## With alternative tooltip
|
|
24
|
+
|
|
25
|
+
If you want to still utilize a tooltip in a similar way to how the `title` attribute works, you can use the [Primer `Tooltip`](https://primer.style/components/tooltip/react/beta). If you use the `Tooltip` component, you must use it with an interactive element, such as with a button or a link.
|
|
26
|
+
|
|
27
|
+
```jsx
|
|
28
|
+
import {RelativeTime, Tooltip} from '@primer/react'
|
|
29
|
+
|
|
30
|
+
const App = () => {
|
|
31
|
+
const date = new Date('2020-01-01T00:00:00Z')
|
|
32
|
+
return (
|
|
33
|
+
<Tooltip text={date.toString()}>
|
|
34
|
+
<Link href="#">
|
|
35
|
+
<RelativeTime date={date} noTitle={true} />
|
|
36
|
+
</Link>
|
|
37
|
+
</Tooltip>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
```
|
package/package-lock.json
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@styled-system/props": "^5.1.5",
|
|
13
|
-
"@typescript-eslint/utils": "8.
|
|
13
|
+
"@typescript-eslint/utils": "8.26.0",
|
|
14
14
|
"eslint-plugin-github": "^5.0.1",
|
|
15
15
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
16
16
|
"eslint-traverse": "^1.0.0",
|
|
17
17
|
"lodash": "^4.17.21",
|
|
18
18
|
"styled-system": "^5.1.5",
|
|
19
|
-
"typescript": "^5.
|
|
19
|
+
"typescript": "^5.8.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@changesets/changelog-github": "^0.5.0",
|
|
@@ -2349,14 +2349,15 @@
|
|
|
2349
2349
|
}
|
|
2350
2350
|
},
|
|
2351
2351
|
"node_modules/@typescript-eslint/utils": {
|
|
2352
|
-
"version": "8.
|
|
2353
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.
|
|
2354
|
-
"integrity": "sha512-
|
|
2352
|
+
"version": "8.26.0",
|
|
2353
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.26.0.tgz",
|
|
2354
|
+
"integrity": "sha512-2L2tU3FVwhvU14LndnQCA2frYC8JnPDVKyQtWFPf8IYFMt/ykEN1bPolNhNbCVgOmdzTlWdusCTKA/9nKrf8Ig==",
|
|
2355
|
+
"license": "MIT",
|
|
2355
2356
|
"dependencies": {
|
|
2356
2357
|
"@eslint-community/eslint-utils": "^4.4.0",
|
|
2357
|
-
"@typescript-eslint/scope-manager": "8.
|
|
2358
|
-
"@typescript-eslint/types": "8.
|
|
2359
|
-
"@typescript-eslint/typescript-estree": "8.
|
|
2358
|
+
"@typescript-eslint/scope-manager": "8.26.0",
|
|
2359
|
+
"@typescript-eslint/types": "8.26.0",
|
|
2360
|
+
"@typescript-eslint/typescript-estree": "8.26.0"
|
|
2360
2361
|
},
|
|
2361
2362
|
"engines": {
|
|
2362
2363
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
@@ -2367,16 +2368,17 @@
|
|
|
2367
2368
|
},
|
|
2368
2369
|
"peerDependencies": {
|
|
2369
2370
|
"eslint": "^8.57.0 || ^9.0.0",
|
|
2370
|
-
"typescript": ">=4.8.4 <5.
|
|
2371
|
+
"typescript": ">=4.8.4 <5.9.0"
|
|
2371
2372
|
}
|
|
2372
2373
|
},
|
|
2373
2374
|
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/scope-manager": {
|
|
2374
|
-
"version": "8.
|
|
2375
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.
|
|
2376
|
-
"integrity": "sha512-
|
|
2375
|
+
"version": "8.26.0",
|
|
2376
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.26.0.tgz",
|
|
2377
|
+
"integrity": "sha512-E0ntLvsfPqnPwng8b8y4OGuzh/iIOm2z8U3S9zic2TeMLW61u5IH2Q1wu0oSTkfrSzwbDJIB/Lm8O3//8BWMPA==",
|
|
2378
|
+
"license": "MIT",
|
|
2377
2379
|
"dependencies": {
|
|
2378
|
-
"@typescript-eslint/types": "8.
|
|
2379
|
-
"@typescript-eslint/visitor-keys": "8.
|
|
2380
|
+
"@typescript-eslint/types": "8.26.0",
|
|
2381
|
+
"@typescript-eslint/visitor-keys": "8.26.0"
|
|
2380
2382
|
},
|
|
2381
2383
|
"engines": {
|
|
2382
2384
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
@@ -2387,9 +2389,10 @@
|
|
|
2387
2389
|
}
|
|
2388
2390
|
},
|
|
2389
2391
|
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": {
|
|
2390
|
-
"version": "8.
|
|
2391
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.
|
|
2392
|
-
"integrity": "sha512-
|
|
2392
|
+
"version": "8.26.0",
|
|
2393
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.26.0.tgz",
|
|
2394
|
+
"integrity": "sha512-89B1eP3tnpr9A8L6PZlSjBvnJhWXtYfZhECqlBl1D9Lme9mHO6iWlsprBtVenQvY1HMhax1mWOjhtL3fh/u+pA==",
|
|
2395
|
+
"license": "MIT",
|
|
2393
2396
|
"engines": {
|
|
2394
2397
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
2395
2398
|
},
|
|
@@ -2399,18 +2402,19 @@
|
|
|
2399
2402
|
}
|
|
2400
2403
|
},
|
|
2401
2404
|
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": {
|
|
2402
|
-
"version": "8.
|
|
2403
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.
|
|
2404
|
-
"integrity": "sha512-
|
|
2405
|
+
"version": "8.26.0",
|
|
2406
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.26.0.tgz",
|
|
2407
|
+
"integrity": "sha512-tiJ1Hvy/V/oMVRTbEOIeemA2XoylimlDQ03CgPPNaHYZbpsc78Hmngnt+WXZfJX1pjQ711V7g0H7cSJThGYfPQ==",
|
|
2408
|
+
"license": "MIT",
|
|
2405
2409
|
"dependencies": {
|
|
2406
|
-
"@typescript-eslint/types": "8.
|
|
2407
|
-
"@typescript-eslint/visitor-keys": "8.
|
|
2410
|
+
"@typescript-eslint/types": "8.26.0",
|
|
2411
|
+
"@typescript-eslint/visitor-keys": "8.26.0",
|
|
2408
2412
|
"debug": "^4.3.4",
|
|
2409
2413
|
"fast-glob": "^3.3.2",
|
|
2410
2414
|
"is-glob": "^4.0.3",
|
|
2411
2415
|
"minimatch": "^9.0.4",
|
|
2412
2416
|
"semver": "^7.6.0",
|
|
2413
|
-
"ts-api-utils": "^
|
|
2417
|
+
"ts-api-utils": "^2.0.1"
|
|
2414
2418
|
},
|
|
2415
2419
|
"engines": {
|
|
2416
2420
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
@@ -2420,15 +2424,16 @@
|
|
|
2420
2424
|
"url": "https://opencollective.com/typescript-eslint"
|
|
2421
2425
|
},
|
|
2422
2426
|
"peerDependencies": {
|
|
2423
|
-
"typescript": ">=4.8.4 <5.
|
|
2427
|
+
"typescript": ">=4.8.4 <5.9.0"
|
|
2424
2428
|
}
|
|
2425
2429
|
},
|
|
2426
2430
|
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": {
|
|
2427
|
-
"version": "8.
|
|
2428
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.
|
|
2429
|
-
"integrity": "sha512-
|
|
2431
|
+
"version": "8.26.0",
|
|
2432
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.26.0.tgz",
|
|
2433
|
+
"integrity": "sha512-2z8JQJWAzPdDd51dRQ/oqIJxe99/hoLIqmf8RMCAJQtYDc535W/Jt2+RTP4bP0aKeBG1F65yjIZuczOXCmbWwg==",
|
|
2434
|
+
"license": "MIT",
|
|
2430
2435
|
"dependencies": {
|
|
2431
|
-
"@typescript-eslint/types": "8.
|
|
2436
|
+
"@typescript-eslint/types": "8.26.0",
|
|
2432
2437
|
"eslint-visitor-keys": "^4.2.0"
|
|
2433
2438
|
},
|
|
2434
2439
|
"engines": {
|
|
@@ -2443,6 +2448,7 @@
|
|
|
2443
2448
|
"version": "2.0.1",
|
|
2444
2449
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
|
|
2445
2450
|
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
|
|
2451
|
+
"license": "MIT",
|
|
2446
2452
|
"dependencies": {
|
|
2447
2453
|
"balanced-match": "^1.0.0"
|
|
2448
2454
|
}
|
|
@@ -2451,6 +2457,7 @@
|
|
|
2451
2457
|
"version": "4.2.0",
|
|
2452
2458
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz",
|
|
2453
2459
|
"integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==",
|
|
2460
|
+
"license": "Apache-2.0",
|
|
2454
2461
|
"engines": {
|
|
2455
2462
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
2456
2463
|
},
|
|
@@ -2462,6 +2469,7 @@
|
|
|
2462
2469
|
"version": "9.0.5",
|
|
2463
2470
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
|
|
2464
2471
|
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
|
|
2472
|
+
"license": "ISC",
|
|
2465
2473
|
"dependencies": {
|
|
2466
2474
|
"brace-expansion": "^2.0.1"
|
|
2467
2475
|
},
|
|
@@ -2473,9 +2481,10 @@
|
|
|
2473
2481
|
}
|
|
2474
2482
|
},
|
|
2475
2483
|
"node_modules/@typescript-eslint/utils/node_modules/semver": {
|
|
2476
|
-
"version": "7.
|
|
2477
|
-
"resolved": "https://registry.npmjs.org/semver/-/semver-7.
|
|
2478
|
-
"integrity": "sha512-
|
|
2484
|
+
"version": "7.7.1",
|
|
2485
|
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz",
|
|
2486
|
+
"integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==",
|
|
2487
|
+
"license": "ISC",
|
|
2479
2488
|
"bin": {
|
|
2480
2489
|
"semver": "bin/semver.js"
|
|
2481
2490
|
},
|
|
@@ -2483,6 +2492,18 @@
|
|
|
2483
2492
|
"node": ">=10"
|
|
2484
2493
|
}
|
|
2485
2494
|
},
|
|
2495
|
+
"node_modules/@typescript-eslint/utils/node_modules/ts-api-utils": {
|
|
2496
|
+
"version": "2.0.1",
|
|
2497
|
+
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.0.1.tgz",
|
|
2498
|
+
"integrity": "sha512-dnlgjFSVetynI8nzgJ+qF62efpglpWRk8isUEWZGWlJYySCTD6aKvbUDu+zbPeDakk3bg5H4XpitHukgfL1m9w==",
|
|
2499
|
+
"license": "MIT",
|
|
2500
|
+
"engines": {
|
|
2501
|
+
"node": ">=18.12"
|
|
2502
|
+
},
|
|
2503
|
+
"peerDependencies": {
|
|
2504
|
+
"typescript": ">=4.8.4"
|
|
2505
|
+
}
|
|
2506
|
+
},
|
|
2486
2507
|
"node_modules/@typescript-eslint/visitor-keys": {
|
|
2487
2508
|
"version": "7.1.1",
|
|
2488
2509
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.1.1.tgz",
|
|
@@ -8206,9 +8227,10 @@
|
|
|
8206
8227
|
}
|
|
8207
8228
|
},
|
|
8208
8229
|
"node_modules/typescript": {
|
|
8209
|
-
"version": "5.
|
|
8210
|
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.
|
|
8211
|
-
"integrity": "sha512-
|
|
8230
|
+
"version": "5.8.2",
|
|
8231
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz",
|
|
8232
|
+
"integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==",
|
|
8233
|
+
"license": "Apache-2.0",
|
|
8212
8234
|
"bin": {
|
|
8213
8235
|
"tsc": "bin/tsc",
|
|
8214
8236
|
"tsserver": "bin/tsserver"
|
|
@@ -10279,51 +10301,51 @@
|
|
|
10279
10301
|
}
|
|
10280
10302
|
},
|
|
10281
10303
|
"@typescript-eslint/utils": {
|
|
10282
|
-
"version": "8.
|
|
10283
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.
|
|
10284
|
-
"integrity": "sha512-
|
|
10304
|
+
"version": "8.26.0",
|
|
10305
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.26.0.tgz",
|
|
10306
|
+
"integrity": "sha512-2L2tU3FVwhvU14LndnQCA2frYC8JnPDVKyQtWFPf8IYFMt/ykEN1bPolNhNbCVgOmdzTlWdusCTKA/9nKrf8Ig==",
|
|
10285
10307
|
"requires": {
|
|
10286
10308
|
"@eslint-community/eslint-utils": "^4.4.0",
|
|
10287
|
-
"@typescript-eslint/scope-manager": "8.
|
|
10288
|
-
"@typescript-eslint/types": "8.
|
|
10289
|
-
"@typescript-eslint/typescript-estree": "8.
|
|
10309
|
+
"@typescript-eslint/scope-manager": "8.26.0",
|
|
10310
|
+
"@typescript-eslint/types": "8.26.0",
|
|
10311
|
+
"@typescript-eslint/typescript-estree": "8.26.0"
|
|
10290
10312
|
},
|
|
10291
10313
|
"dependencies": {
|
|
10292
10314
|
"@typescript-eslint/scope-manager": {
|
|
10293
|
-
"version": "8.
|
|
10294
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.
|
|
10295
|
-
"integrity": "sha512-
|
|
10315
|
+
"version": "8.26.0",
|
|
10316
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.26.0.tgz",
|
|
10317
|
+
"integrity": "sha512-E0ntLvsfPqnPwng8b8y4OGuzh/iIOm2z8U3S9zic2TeMLW61u5IH2Q1wu0oSTkfrSzwbDJIB/Lm8O3//8BWMPA==",
|
|
10296
10318
|
"requires": {
|
|
10297
|
-
"@typescript-eslint/types": "8.
|
|
10298
|
-
"@typescript-eslint/visitor-keys": "8.
|
|
10319
|
+
"@typescript-eslint/types": "8.26.0",
|
|
10320
|
+
"@typescript-eslint/visitor-keys": "8.26.0"
|
|
10299
10321
|
}
|
|
10300
10322
|
},
|
|
10301
10323
|
"@typescript-eslint/types": {
|
|
10302
|
-
"version": "8.
|
|
10303
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.
|
|
10304
|
-
"integrity": "sha512-
|
|
10324
|
+
"version": "8.26.0",
|
|
10325
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.26.0.tgz",
|
|
10326
|
+
"integrity": "sha512-89B1eP3tnpr9A8L6PZlSjBvnJhWXtYfZhECqlBl1D9Lme9mHO6iWlsprBtVenQvY1HMhax1mWOjhtL3fh/u+pA=="
|
|
10305
10327
|
},
|
|
10306
10328
|
"@typescript-eslint/typescript-estree": {
|
|
10307
|
-
"version": "8.
|
|
10308
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.
|
|
10309
|
-
"integrity": "sha512-
|
|
10329
|
+
"version": "8.26.0",
|
|
10330
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.26.0.tgz",
|
|
10331
|
+
"integrity": "sha512-tiJ1Hvy/V/oMVRTbEOIeemA2XoylimlDQ03CgPPNaHYZbpsc78Hmngnt+WXZfJX1pjQ711V7g0H7cSJThGYfPQ==",
|
|
10310
10332
|
"requires": {
|
|
10311
|
-
"@typescript-eslint/types": "8.
|
|
10312
|
-
"@typescript-eslint/visitor-keys": "8.
|
|
10333
|
+
"@typescript-eslint/types": "8.26.0",
|
|
10334
|
+
"@typescript-eslint/visitor-keys": "8.26.0",
|
|
10313
10335
|
"debug": "^4.3.4",
|
|
10314
10336
|
"fast-glob": "^3.3.2",
|
|
10315
10337
|
"is-glob": "^4.0.3",
|
|
10316
10338
|
"minimatch": "^9.0.4",
|
|
10317
10339
|
"semver": "^7.6.0",
|
|
10318
|
-
"ts-api-utils": "^
|
|
10340
|
+
"ts-api-utils": "^2.0.1"
|
|
10319
10341
|
}
|
|
10320
10342
|
},
|
|
10321
10343
|
"@typescript-eslint/visitor-keys": {
|
|
10322
|
-
"version": "8.
|
|
10323
|
-
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.
|
|
10324
|
-
"integrity": "sha512-
|
|
10344
|
+
"version": "8.26.0",
|
|
10345
|
+
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.26.0.tgz",
|
|
10346
|
+
"integrity": "sha512-2z8JQJWAzPdDd51dRQ/oqIJxe99/hoLIqmf8RMCAJQtYDc535W/Jt2+RTP4bP0aKeBG1F65yjIZuczOXCmbWwg==",
|
|
10325
10347
|
"requires": {
|
|
10326
|
-
"@typescript-eslint/types": "8.
|
|
10348
|
+
"@typescript-eslint/types": "8.26.0",
|
|
10327
10349
|
"eslint-visitor-keys": "^4.2.0"
|
|
10328
10350
|
}
|
|
10329
10351
|
},
|
|
@@ -10349,9 +10371,15 @@
|
|
|
10349
10371
|
}
|
|
10350
10372
|
},
|
|
10351
10373
|
"semver": {
|
|
10352
|
-
"version": "7.
|
|
10353
|
-
"resolved": "https://registry.npmjs.org/semver/-/semver-7.
|
|
10354
|
-
"integrity": "sha512-
|
|
10374
|
+
"version": "7.7.1",
|
|
10375
|
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz",
|
|
10376
|
+
"integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA=="
|
|
10377
|
+
},
|
|
10378
|
+
"ts-api-utils": {
|
|
10379
|
+
"version": "2.0.1",
|
|
10380
|
+
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.0.1.tgz",
|
|
10381
|
+
"integrity": "sha512-dnlgjFSVetynI8nzgJ+qF62efpglpWRk8isUEWZGWlJYySCTD6aKvbUDu+zbPeDakk3bg5H4XpitHukgfL1m9w==",
|
|
10382
|
+
"requires": {}
|
|
10355
10383
|
}
|
|
10356
10384
|
}
|
|
10357
10385
|
},
|
|
@@ -14349,9 +14377,9 @@
|
|
|
14349
14377
|
}
|
|
14350
14378
|
},
|
|
14351
14379
|
"typescript": {
|
|
14352
|
-
"version": "5.
|
|
14353
|
-
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.
|
|
14354
|
-
"integrity": "sha512-
|
|
14380
|
+
"version": "5.8.2",
|
|
14381
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz",
|
|
14382
|
+
"integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ=="
|
|
14355
14383
|
},
|
|
14356
14384
|
"uc.micro": {
|
|
14357
14385
|
"version": "2.1.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-primer-react",
|
|
3
|
-
"version": "7.0.0-rc.
|
|
3
|
+
"version": "7.0.0-rc.5c89573",
|
|
4
4
|
"description": "ESLint rules for Primer React",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"eslint-traverse": "^1.0.0",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
36
|
"styled-system": "^5.1.5",
|
|
37
|
-
"@typescript-eslint/utils": "8.
|
|
38
|
-
"typescript": "^5.
|
|
37
|
+
"@typescript-eslint/utils": "8.26.0",
|
|
38
|
+
"typescript": "^5.8.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@changesets/changelog-github": "^0.5.0",
|
|
@@ -15,6 +15,7 @@ module.exports = {
|
|
|
15
15
|
'primer-react/a11y-tooltip-interactive-trigger': 'error',
|
|
16
16
|
'primer-react/new-color-css-vars': 'error',
|
|
17
17
|
'primer-react/a11y-explicit-heading': 'error',
|
|
18
|
+
'primer-react/a11y-no-title-usage': 'error',
|
|
18
19
|
'primer-react/no-deprecated-props': 'warn',
|
|
19
20
|
'primer-react/a11y-remove-disable-tooltip': 'error',
|
|
20
21
|
'primer-react/a11y-use-accessible-tooltip': 'error',
|
package/src/index.js
CHANGED
|
@@ -10,6 +10,7 @@ module.exports = {
|
|
|
10
10
|
'a11y-link-in-text-block': require('./rules/a11y-link-in-text-block'),
|
|
11
11
|
'a11y-remove-disable-tooltip': require('./rules/a11y-remove-disable-tooltip'),
|
|
12
12
|
'a11y-use-accessible-tooltip': require('./rules/a11y-use-accessible-tooltip'),
|
|
13
|
+
'a11y-no-title-usage': require('./rules/a11y-no-title-usage'),
|
|
13
14
|
'use-deprecated-from-deprecated': require('./rules/use-deprecated-from-deprecated'),
|
|
14
15
|
'no-wildcard-imports': require('./rules/no-wildcard-imports'),
|
|
15
16
|
'no-unnecessary-components': require('./rules/no-unnecessary-components'),
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const rule = require('../a11y-no-title-usage')
|
|
2
|
+
const {RuleTester} = require('eslint')
|
|
3
|
+
|
|
4
|
+
const ruleTester = new RuleTester({
|
|
5
|
+
parserOptions: {
|
|
6
|
+
ecmaVersion: 'latest',
|
|
7
|
+
sourceType: 'module',
|
|
8
|
+
ecmaFeatures: {
|
|
9
|
+
jsx: true,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
ruleTester.run('a11y-no-title-usage', rule, {
|
|
15
|
+
valid: [
|
|
16
|
+
`<RelativeTime date={new Date('2020-01-01T00:00:00Z')} noTitle={true} />`,
|
|
17
|
+
`<RelativeTime date={new Date('2020-01-01T00:00:00Z')} noTitle />`,
|
|
18
|
+
`<RelativeTime date={new Date('2020-01-01T00:00:00Z')} />`,
|
|
19
|
+
],
|
|
20
|
+
invalid: [
|
|
21
|
+
{
|
|
22
|
+
code: `<RelativeTime date={new Date('2020-01-01T00:00:00Z')} noTitle={false} />`,
|
|
23
|
+
output: `<RelativeTime date={new Date('2020-01-01T00:00:00Z')} />`,
|
|
24
|
+
errors: [{messageId: 'noTitleOnRelativeTime'}],
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
})
|
|
@@ -67,6 +67,22 @@ ruleTester.run('non-interactive-tooltip-trigger', rule, {
|
|
|
67
67
|
</Link>
|
|
68
68
|
</Tooltip>
|
|
69
69
|
`,
|
|
70
|
+
`
|
|
71
|
+
import {Tooltip, Link} from '@primer/react';
|
|
72
|
+
<Tooltip aria-label="product" direction="e">
|
|
73
|
+
<Link to={productLink}>
|
|
74
|
+
Product
|
|
75
|
+
</Link>
|
|
76
|
+
</Tooltip>
|
|
77
|
+
`,
|
|
78
|
+
`
|
|
79
|
+
import {Tooltip, Link} from '@primer/react';
|
|
80
|
+
<Tooltip aria-label="product" direction="e">
|
|
81
|
+
<Link to="https://github.com">
|
|
82
|
+
Product
|
|
83
|
+
</Link>
|
|
84
|
+
</Tooltip>
|
|
85
|
+
`,
|
|
70
86
|
],
|
|
71
87
|
invalid: [
|
|
72
88
|
{
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const url = require('../url')
|
|
2
|
+
const {getJSXOpeningElementAttribute} = require('../utils/get-jsx-opening-element-attribute')
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
meta: {
|
|
6
|
+
type: 'error',
|
|
7
|
+
docs: {
|
|
8
|
+
description: 'Disallow usage of title attribute on some components',
|
|
9
|
+
recommended: true,
|
|
10
|
+
url: url(module),
|
|
11
|
+
},
|
|
12
|
+
messages: {
|
|
13
|
+
noTitleOnRelativeTime: 'Avoid using the title attribute on RelativeTime.',
|
|
14
|
+
},
|
|
15
|
+
fixable: 'code',
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
create(context) {
|
|
19
|
+
return {
|
|
20
|
+
JSXOpeningElement(jsxNode) {
|
|
21
|
+
const title = getJSXOpeningElementAttribute(jsxNode, 'noTitle')
|
|
22
|
+
|
|
23
|
+
if (title && title.value && title.value.expression && title.value.expression.value !== true) {
|
|
24
|
+
context.report({
|
|
25
|
+
node: title,
|
|
26
|
+
messageId: 'noTitleOnRelativeTime',
|
|
27
|
+
fix(fixer) {
|
|
28
|
+
const start = title.range[0] - 1
|
|
29
|
+
const end = title.range[1]
|
|
30
|
+
return fixer.removeRange([start, end])
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
}
|
|
@@ -23,7 +23,7 @@ const isAnchorTag = el => {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const isJSXValue = attributes => {
|
|
26
|
-
const node = attributes.find(attribute => propName(attribute) === 'href')
|
|
26
|
+
const node = attributes.find(attribute => propName(attribute) === 'href' || propName(attribute))
|
|
27
27
|
const isJSXExpression = node.value.type === 'JSXExpressionContainer' && node && typeof getPropValue(node) === 'string'
|
|
28
28
|
|
|
29
29
|
return isJSXExpression
|
|
@@ -31,8 +31,14 @@ const isJSXValue = attributes => {
|
|
|
31
31
|
|
|
32
32
|
const isInteractiveAnchor = child => {
|
|
33
33
|
const hasHref = getJSXOpeningElementAttribute(child.openingElement, 'href')
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const hasTo = getJSXOpeningElementAttribute(child.openingElement, 'to')
|
|
35
|
+
|
|
36
|
+
if (!hasHref && !hasTo) return false
|
|
37
|
+
|
|
38
|
+
const href = hasHref
|
|
39
|
+
? getJSXOpeningElementAttribute(child.openingElement, 'href').value.value
|
|
40
|
+
: getJSXOpeningElementAttribute(child.openingElement, 'to').value.value
|
|
41
|
+
|
|
36
42
|
const hasJSXValue = isJSXValue(child.openingElement.attributes)
|
|
37
43
|
const isAnchorInteractive = (typeof href === 'string' && href !== '') || hasJSXValue
|
|
38
44
|
|