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(eslint-plugin): add browser compatibility plugin #33786

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Copy link
Collaborator

@fabricteam fabricteam Feb 5, 2025

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual regressions to review in the fluentuiv8 Visual Regression Report

react-charting-AreaChart 1 screenshots
Image Name Diff(in Pixels) Image Type
react-charting-AreaChart.Custom Accessibility.default.chromium.png 11 Changed
react-charting-HeatMapChart 1 screenshots
Image Name Diff(in Pixels) Image Type
react-charting-HeatMapChart.Basic.default.chromium.png 376 Changed
react-charting-LineChart 1 screenshots
Image Name Diff(in Pixels) Image Type
react-charting-LineChart.Events.default.chromium.png 2 Changed

Copy link
Collaborator

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual regressions to review in the fluentui-web-components-v3 Visual Regression Report

Badge 1 screenshots
Image Name Diff(in Pixels) Image Type
Badge. - Dark Mode.normal.chromium_1.png 511 Changed
Checkbox 1 screenshots
Image Name Diff(in Pixels) Image Type
Checkbox. - Dark Mode.normal.chromium.png 37 Changed
Divider 1 screenshots
Image Name Diff(in Pixels) Image Type
Divider. - RTL.normal.chromium_1.png 103 Changed

"type": "minor",
"comment": "feat: add browser compatibility plugin",
"packageName": "@fluentui/eslint-plugin",
"email": "[email protected]",
"dependentChangeType": "minor"
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
"eslint-config-airbnb": "18.2.1",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-compat": "6.0.2",
"eslint-plugin-es": "4.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jest": "28.8.0",
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-compat": "^6.0.2",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-jsdoc": "^48.7.0",
Expand Down
32 changes: 30 additions & 2 deletions packages/eslint-plugin/src/configs/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

const path = require('path');

const { getNamingConventionRule } = require('../utils/configHelpers');
const { getNamingConventionRule, testFiles, storyFiles } = require('../utils/configHelpers');

/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: [path.join(__dirname, 'core')],
extends: [
path.join(__dirname, 'core'),
// Browser compatibility linter rules
'plugin:compat/recommended',
],
plugins: ['compat'],
rules: {
/**
* `@typescript-eslint`plugin eslint rules
Expand All @@ -24,5 +29,28 @@ module.exports = {
'@rnx-kit/no-export-all': ['error', { expand: 'all' }],
},
},
{
files: [...testFiles, ...storyFiles],
Copy link
Contributor

@Hotell Hotell Feb 17, 2025

Choose a reason for hiding this comment

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

hmm adding it to overrides would be easier for future migration to flat configs and also would make it more readable as exclude + include would be part of same config

if we add it to existing files: '**/src/**/*.{ts,tsx,js}', override

{
      files: '**/src/**/*.{ts,tsx,js}',
      excludedFiles: [...testFiles],
      extends: ['plugin:compat/recommended'],
      plugins: ['compat'],
      settings: {
        // Browser matrix support - https://react.fluentui.dev/?path=/docs/concepts-developer-browser-support-matrix--docs#partial-browser-support-matrix
        targets: [
          // Desktop browsers
          'edge >= 79',
          'firefox >= 69',
          'chrome >= 79',
          'safari >= 13.1',
          'opera >= 64',
          'not ie <= 11',
          // Mobile browsers
          'ios_saf >= 13.4',
          'android >= 79',
          'samsung >= 14',
          'not op_mini all',
        ],
      },

WDYT ?

rules: {
'compat/compat': 'off',
},
},
],
settings: {
// Browser matrix support - https://react.fluentui.dev/?path=/docs/concepts-developer-browser-support-matrix--docs#partial-browser-support-matrix
targets: [
// Desktop browsers
'edge >= 79',
'firefox >= 69',
'chrome >= 79',
'safari >= 13.1',
'opera >= 64',
'not ie <= 11',
// Mobile browsers
'ios_saf >= 13.4',
'android >= 79',
'samsung >= 14',
'not op_mini all',
],
},
};
3 changes: 3 additions & 0 deletions packages/eslint-plugin/src/utils/configHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ module.exports = {
*/
devDependenciesFiles: [...testFiles, ...docsFiles, ...configFiles, ...storyFiles],

/** Storybook stories */
storyFiles,

/**
* Whether linting is running in context of lint-staged (which should disable rules requiring
* type info due to their significant perf penalty).
Expand Down
1 change: 1 addition & 0 deletions syncpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const config = {
'eslint-config-airbnb',
'eslint-config-prettier',
'eslint-import-resolver-typescript',
'eslint-plugin-compat',
'eslint-plugin-import',
'eslint-plugin-jest',
'eslint-plugin-jsx-a11y',
Expand Down
70 changes: 48 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,11 @@
resolved "https://registry.yarnpkg.com/@linaria/utils/-/utils-3.0.0-beta.20.tgz#0965df816120a1973c4559b746571c01c6cb9bef"
integrity sha512-SKRC9dBApzu0kTksVtGZ7eJz1vMu7xew/JEAjQj6XTQDblzWpTPyKQHBOGXNkqXjIB8PwAqWfvKzKapzaOwQaQ==

"@mdn/browser-compat-data@^5.5.35", "@mdn/browser-compat-data@^5.6.19":
version "5.6.36"
resolved "https://registry.yarnpkg.com/@mdn/browser-compat-data/-/browser-compat-data-5.6.36.tgz#209c3a37aa1b2cbd503cfa7bb0755084a50cc1ff"
integrity sha512-UhTBGnR9L8x1hpCA/VlVxwY8CXfyWPoTDAlWz5n1iwJxDaiqA0XkTfi5p6FuHMHE/EuUUtfiSIu14nzQUtJPDg==

"@mdx-js/[email protected]":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@mdx-js/loader/-/loader-2.3.0.tgz#56a6b07eb0027b6407e953a97c52bd8619601161"
Expand Down Expand Up @@ -7167,6 +7172,13 @@ assign-symbols@^1.0.0:
resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=

ast-metadata-inferer@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/ast-metadata-inferer/-/ast-metadata-inferer-0.8.1.tgz#85081bf30308acd4c35fb8694658b4c5f6f3ee60"
integrity sha512-ht3Dm6Zr7SXv6t1Ra6gFo0+kLDglHGrEbYihTkcycrbHw7WCcuhBzPlJYHEsIpycaUwzsJHje+vUcxXUX4ztTA==
dependencies:
"@mdn/browser-compat-data" "^5.6.19"

ast-types-flow@^0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.8.tgz#0a85e1c92695769ac13a428bb653e7538bea27d6"
Expand Down Expand Up @@ -7844,15 +7856,15 @@ browserify-zlib@^0.1.4:
dependencies:
pako "~0.2.0"

browserslist@^4.16.1, browserslist@^4.21.10, browserslist@^4.23.0, browserslist@^4.23.1:
version "4.23.2"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.23.2.tgz#244fe803641f1c19c28c48c4b6ec9736eb3d32ed"
integrity sha512-qkqSyistMYdxAcw+CzbZwlBy8AGmS/eEWs+sEV5TnLRGDOL+C5M2EnH6tlZyg0YoAxGJAFKh61En9BR941GnHA==
browserslist@^4.16.1, browserslist@^4.21.10, browserslist@^4.23.0, browserslist@^4.23.1, browserslist@^4.24.2:
version "4.24.4"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.4.tgz#c6b2865a3f08bcb860a0e827389003b9fe686e4b"
integrity sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A==
dependencies:
caniuse-lite "^1.0.30001640"
electron-to-chromium "^1.4.820"
node-releases "^2.0.14"
update-browserslist-db "^1.1.0"
caniuse-lite "^1.0.30001688"
electron-to-chromium "^1.5.73"
node-releases "^2.0.19"
update-browserslist-db "^1.1.1"

bs-logger@^0.2.6:
version "0.2.6"
Expand Down Expand Up @@ -8080,7 +8092,7 @@ camelcase@^6.0.0, camelcase@^6.2.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.1.tgz#250fd350cfd555d0d2160b1d51510eaf8326e86e"
integrity sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA==

caniuse-lite@^1.0.30001173, caniuse-lite@^1.0.30001640:
caniuse-lite@^1.0.30001173, caniuse-lite@^1.0.30001687, caniuse-lite@^1.0.30001688:
version "1.0.30001699"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001699.tgz"
integrity sha512-b+uH5BakXZ9Do9iK+CkDmctUSEqZl+SP056vc5usa0PL+ev5OHw003rZXcnjNDv3L8P5j6rwT6C0BPKSikW08w==
Expand Down Expand Up @@ -10418,10 +10430,10 @@ [email protected]:
dependencies:
jake "^10.8.5"

electron-to-chromium@^1.4.820:
version "1.5.4"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.4.tgz#cd477c830dd6fca41fbd5465c1ff6ce08ac22343"
integrity sha512-orzA81VqLyIGUEA77YkVA1D+N+nNfl2isJVjjmOyrlxuooZ19ynb+dOlaDTqd/idKRS9lDCSBmtzM+kyCsMnkA==
electron-to-chromium@^1.5.73:
version "1.5.92"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.92.tgz#81e8ebe06f8e2a49fdba84bd10e9ad5b63efffe0"
integrity sha512-BeHgmNobs05N1HMmMZ7YIuHfYBGlq/UmvlsTgg+fsbFs9xVMj+xJHFg19GN04+9Q+r8Xnh9LXqaYIyEWElnNgQ==

[email protected], embla-carousel-autoplay@^8.5.1:
version "8.5.1"
Expand Down Expand Up @@ -10923,6 +10935,20 @@ eslint-module-utils@^2.7.4, eslint-module-utils@^2.8.0:
dependencies:
debug "^3.2.7"

[email protected], eslint-plugin-compat@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-compat/-/eslint-plugin-compat-6.0.2.tgz#34840c97047b58f1ae012d61a46abb09af7bb0ab"
integrity sha512-1ME+YfJjmOz1blH0nPZpHgjMGK4kjgEeoYqGCqoBPQ/mGu/dJzdoP0f1C8H2jcWZjzhZjAMccbM/VdXhPORIfA==
dependencies:
"@mdn/browser-compat-data" "^5.5.35"
ast-metadata-inferer "^0.8.1"
browserslist "^4.24.2"
caniuse-lite "^1.0.30001687"
find-up "^5.0.0"
globals "^15.7.0"
lodash.memoize "^4.1.2"
semver "^7.6.2"

[email protected]:
version "4.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz#f0822f0c18a535a97c3e714e89f88586a7641ec9"
Expand Down Expand Up @@ -12857,10 +12883,10 @@ globals@^11.1.0:
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==

globals@^15.9.0:
version "15.9.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-15.9.0.tgz#e9de01771091ffbc37db5714dab484f9f69ff399"
integrity sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==
globals@^15.7.0, globals@^15.9.0:
version "15.14.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-15.14.0.tgz#b8fd3a8941ff3b4d38f3319d433b61bbb482e73f"
integrity sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==

globalthis@^1.0.3:
version "1.0.4"
Expand Down Expand Up @@ -17842,10 +17868,10 @@ [email protected], node-plop@~0.25.0:
mkdirp "^0.5.1"
resolve "^1.12.0"

node-releases@^2.0.14:
version "2.0.14"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b"
integrity sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==
node-releases@^2.0.19:
version "2.0.19"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.19.tgz#9e445a52950951ec4d177d843af370b411caf314"
integrity sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==

normalize-package-data@^2.3.2, normalize-package-data@^2.5.0:
version "2.5.0"
Expand Down Expand Up @@ -23438,7 +23464,7 @@ upath@^1.1.1:
resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.2.tgz#3db658600edaeeccbe6db5e684d67ee8c2acd068"
integrity sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==

update-browserslist-db@^1.1.0:
update-browserslist-db@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.2.tgz#97e9c96ab0ae7bcac08e9ae5151d26e6bc6b5580"
integrity sha512-PPypAm5qvlD7XMZC3BujecnaOxwhrtoFR+Dqkk5Aa/6DssiH0ibKoketaj9w8LP7Bont1rYeoV5plxD7RTEPRg==
Expand Down