diff --git a/change/@fluentui-eslint-plugin-728becf6-2abf-400f-b3bc-7a5049b39ba9.json b/change/@fluentui-eslint-plugin-728becf6-2abf-400f-b3bc-7a5049b39ba9.json new file mode 100644 index 0000000000000..87ac5043ecf19 --- /dev/null +++ b/change/@fluentui-eslint-plugin-728becf6-2abf-400f-b3bc-7a5049b39ba9.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "feat: add browser compatibility plugin", + "packageName": "@fluentui/eslint-plugin", + "email": "dmytrokirpa@microsoft.com", + "dependentChangeType": "minor" +} diff --git a/package.json b/package.json index 05463a36c1548..030344cc5d87a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 87282caa80023..33b3c163065d8 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -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", diff --git a/packages/eslint-plugin/src/configs/base.js b/packages/eslint-plugin/src/configs/base.js index cab360135da70..18f0d63ea6556 100644 --- a/packages/eslint-plugin/src/configs/base.js +++ b/packages/eslint-plugin/src/configs/base.js @@ -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 @@ -24,5 +29,28 @@ module.exports = { '@rnx-kit/no-export-all': ['error', { expand: 'all' }], }, }, + { + files: [...testFiles, ...storyFiles], + 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', + ], + }, }; diff --git a/packages/eslint-plugin/src/utils/configHelpers.js b/packages/eslint-plugin/src/utils/configHelpers.js index 209d408179af1..1b9c97618cfb0 100644 --- a/packages/eslint-plugin/src/utils/configHelpers.js +++ b/packages/eslint-plugin/src/utils/configHelpers.js @@ -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). diff --git a/syncpack.config.js b/syncpack.config.js index 0e3e0b1fcdc4a..35733719a9dff 100644 --- a/syncpack.config.js +++ b/syncpack.config.js @@ -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', diff --git a/yarn.lock b/yarn.lock index 383162a8ccd77..22d4270b6beb2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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/loader@2.3.0": version "2.3.0" resolved "https://registry.yarnpkg.com/@mdx-js/loader/-/loader-2.3.0.tgz#56a6b07eb0027b6407e953a97c52bd8619601161" @@ -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" @@ -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" @@ -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== @@ -10418,10 +10430,10 @@ ejs@3.1.9: 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== embla-carousel-autoplay@8.5.1, embla-carousel-autoplay@^8.5.1: version "8.5.1" @@ -10923,6 +10935,20 @@ eslint-module-utils@^2.7.4, eslint-module-utils@^2.8.0: dependencies: debug "^3.2.7" +eslint-plugin-compat@6.0.2, 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" + eslint-plugin-es@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz#f0822f0c18a535a97c3e714e89f88586a7641ec9" @@ -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" @@ -17842,10 +17868,10 @@ node-plop@0.25.0, 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" @@ -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==