From 7f56f76f0da766e16fe6fa7384e2d3f0e05ee29b Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 12 May 2022 11:32:58 +0200 Subject: [PATCH 1/3] chore: enable ESLint plugin for Griffel --- package.json | 1 + packages/eslint-plugin/src/configs/react.js | 2 + yarn.lock | 97 ++++++++++++++++++++- 3 files changed, 99 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 25407ad3e76cb9..4fdc988906fa50 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "@cypress/webpack-dev-server": "1.8.3", "@fluentui/react-icons": "^2.0.166-rc.3", "@griffel/babel-preset": "1.2.0", + "@griffel/eslint-plugin": "1.0.0", "@griffel/jest-serializer": "1.0.3", "@griffel/react": "1.0.3", "@griffel/webpack-loader": "2.0.3", diff --git a/packages/eslint-plugin/src/configs/react.js b/packages/eslint-plugin/src/configs/react.js index b816184207e28b..e288804543435a 100644 --- a/packages/eslint-plugin/src/configs/react.js +++ b/packages/eslint-plugin/src/configs/react.js @@ -7,6 +7,7 @@ const config = { extends: [ // Provides both rules and some parser options and other settings 'airbnb', + 'plugin:@griffel/recommended', // add typescript support for import plugin - https://github.com/import-js/eslint-plugin-import/blob/main/config/typescript.js 'plugin:import/typescript', // Extended configs are applied in order, so these configs that turn other rules off should come last @@ -16,6 +17,7 @@ const config = { plugins: [ 'import', '@fluentui', + '@griffel', '@rnx-kit', '@typescript-eslint', 'deprecation', diff --git a/yarn.lock b/yarn.lock index bb5c40f0df9266..b5f1ec2010da1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1717,6 +1717,14 @@ stylis "^4.0.13" tslib "^2.1.0" +"@griffel/eslint-plugin@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@griffel/eslint-plugin/-/eslint-plugin-1.0.0.tgz#cba251b7a140399c6686b72a72e9fa2ee481f532" + integrity sha512-I8oQcyTdcPmOqX4Ti7FVP8fTJRneQBhzNf6eh8ce7avvVF7YOkiIg+Qu9dVvXSR/BxkY/Ncs8CGtUV++kTBx0g== + dependencies: + "@typescript-eslint/utils" "^5.20.0" + csstype "^3.0.10" + "@griffel/jest-serializer@1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@griffel/jest-serializer/-/jest-serializer-1.0.3.tgz#f8020480a699f0bf278ed61d2a12fbffa40aa62e" @@ -5911,11 +5919,24 @@ "@typescript-eslint/types" "4.22.0" "@typescript-eslint/visitor-keys" "4.22.0" +"@typescript-eslint/scope-manager@5.23.0": + version "5.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.23.0.tgz#4305e61c2c8e3cfa3787d30f54e79430cc17ce1b" + integrity sha512-EhjaFELQHCRb5wTwlGsNMvzK9b8Oco4aYNleeDlNuL6qXWDF47ch4EhVNPh8Rdhf9tmqbN4sWDk/8g+Z/J8JVw== + dependencies: + "@typescript-eslint/types" "5.23.0" + "@typescript-eslint/visitor-keys" "5.23.0" + "@typescript-eslint/types@4.22.0": version "4.22.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.22.0.tgz#0ca6fde5b68daf6dba133f30959cc0688c8dd0b6" integrity sha512-sW/BiXmmyMqDPO2kpOhSy2Py5w6KvRRsKZnV0c4+0nr4GIcedJwXAq+RHNK4lLVEZAJYFltnnk1tJSlbeS9lYA== +"@typescript-eslint/types@5.23.0": + version "5.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.23.0.tgz#8733de0f58ae0ed318dbdd8f09868cdbf9f9ad09" + integrity sha512-NfBsV/h4dir/8mJwdZz7JFibaKC3E/QdeMEDJhiAE3/eMkoniZ7MjbEMCGXw6MZnZDMN3G9S0mH/6WUIj91dmw== + "@typescript-eslint/typescript-estree@4.22.0": version "4.22.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.0.tgz#b5d95d6d366ff3b72f5168c75775a3e46250d05c" @@ -5929,6 +5950,31 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@5.23.0": + version "5.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.23.0.tgz#dca5f10a0a85226db0796e8ad86addc9aee52065" + integrity sha512-xE9e0lrHhI647SlGMl+m+3E3CKPF1wzvvOEWnuE3CCjjT7UiRnDGJxmAcVKJIlFgK6DY9RB98eLr1OPigPEOGg== + dependencies: + "@typescript-eslint/types" "5.23.0" + "@typescript-eslint/visitor-keys" "5.23.0" + debug "^4.3.2" + globby "^11.0.4" + is-glob "^4.0.3" + semver "^7.3.5" + tsutils "^3.21.0" + +"@typescript-eslint/utils@^5.20.0": + version "5.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.23.0.tgz#4691c3d1b414da2c53d8943310df36ab1c50648a" + integrity sha512-dbgaKN21drqpkbbedGMNPCtRPZo1IOUr5EI9Jrrh99r5UW5Q0dz46RKXeSBoPV+56R6dFKpbrdhgUNSJsDDRZA== + dependencies: + "@types/json-schema" "^7.0.9" + "@typescript-eslint/scope-manager" "5.23.0" + "@typescript-eslint/types" "5.23.0" + "@typescript-eslint/typescript-estree" "5.23.0" + eslint-scope "^5.1.1" + eslint-utils "^3.0.0" + "@typescript-eslint/visitor-keys@4.22.0": version "4.22.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.0.tgz#169dae26d3c122935da7528c839f42a8a42f6e47" @@ -5937,6 +5983,14 @@ "@typescript-eslint/types" "4.22.0" eslint-visitor-keys "^2.0.0" +"@typescript-eslint/visitor-keys@5.23.0": + version "5.23.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.23.0.tgz#057c60a7ca64667a39f991473059377a8067c87b" + integrity sha512-Vd4mFNchU62sJB8pX19ZSPog05B0Y0CE2UxAZPT5k4iqhRYjPnqyY3woMxCd0++t9OTqkgjST+1ydLBi7e2Fvg== + dependencies: + "@typescript-eslint/types" "5.23.0" + eslint-visitor-keys "^3.0.0" + "@uifabric/merge-styles@^7.19.1": version "7.19.1" resolved "https://registry.yarnpkg.com/@uifabric/merge-styles/-/merge-styles-7.19.1.tgz#446b3da48ce9925d1649edd0fc232221974b00c9" @@ -11940,6 +11994,13 @@ eslint-utils@^2.0.0, eslint-utils@^2.1.0: dependencies: eslint-visitor-keys "^1.1.0" +eslint-utils@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-3.0.0.tgz#8aebaface7345bb33559db0a1f13a1d2d48c3672" + integrity sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA== + dependencies: + eslint-visitor-keys "^2.0.0" + eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" @@ -11950,6 +12011,11 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== +eslint-visitor-keys@^3.0.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" + integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== + eslint@7.25.0: version "7.25.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.25.0.tgz#1309e4404d94e676e3e831b3a3ad2b050031eb67" @@ -12486,7 +12552,7 @@ fast-glob@^3.0.3, fast-glob@^3.1.1, fast-glob@^3.2.2, fast-glob@^3.2.5: micromatch "^4.0.2" picomatch "^2.2.1" -fast-glob@^3.2.7: +fast-glob@^3.2.7, fast-glob@^3.2.9: version "3.2.11" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== @@ -13866,6 +13932,18 @@ globby@^10.0.1: merge2 "^1.2.3" slash "^3.0.0" +globby@^11.0.4: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" + slash "^3.0.0" + globby@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" @@ -14933,6 +15011,11 @@ ignore@^5.0.4, ignore@^5.1.1, ignore@^5.1.4: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== +ignore@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a" + integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ== + immer@^9.0.12: version "9.0.12" resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.12.tgz#2d33ddf3ee1d247deab9d707ca472c8c942a0f20" @@ -18597,6 +18680,11 @@ merge2@^1.3.0: resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.3.0.tgz#5b366ee83b2f1582c48f87e47cf1a9352103ca81" integrity sha512-2j4DAdlBOkiSZIsaXk4mTE3sRS02yBHAtfy127xRV3bQUFqXkjHCHLW6Scv7DwNRbIWNHH8zpnz9zMaKXIdvYw== +merge2@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + methods@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" @@ -25358,6 +25446,13 @@ tsutils@^3.0.0, tsutils@^3.17.1: dependencies: tslib "^1.8.1" +tsutils@^3.21.0: + version "3.21.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" + integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== + dependencies: + tslib "^1.8.1" + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" From 39936ba2c71a897164a071615ca20322ae99a991 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 12 May 2022 11:37:04 +0200 Subject: [PATCH 2/3] add change file --- ...eslint-plugin-83177480-e2f6-4ac0-9bf2-85d57cb5dc2a.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@fluentui-eslint-plugin-83177480-e2f6-4ac0-9bf2-85d57cb5dc2a.json diff --git a/change/@fluentui-eslint-plugin-83177480-e2f6-4ac0-9bf2-85d57cb5dc2a.json b/change/@fluentui-eslint-plugin-83177480-e2f6-4ac0-9bf2-85d57cb5dc2a.json new file mode 100644 index 00000000000000..2257f7205b78c4 --- /dev/null +++ b/change/@fluentui-eslint-plugin-83177480-e2f6-4ac0-9bf2-85d57cb5dc2a.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "feat: add new rules covering usage of Griffel", + "packageName": "@fluentui/eslint-plugin", + "email": "olfedias@microsoft.com", + "dependentChangeType": "patch" +} From b45847722874da253b8cdf397b4021f57dfeaa14 Mon Sep 17 00:00:00 2001 From: Oleksandr Fediashov Date: Thu, 12 May 2022 12:10:31 +0200 Subject: [PATCH 3/3] fix config for legacy --- packages/eslint-plugin/src/configs/react-legacy.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-plugin/src/configs/react-legacy.js b/packages/eslint-plugin/src/configs/react-legacy.js index 1c469a2e1ba34e..119f72aca8418f 100644 --- a/packages/eslint-plugin/src/configs/react-legacy.js +++ b/packages/eslint-plugin/src/configs/react-legacy.js @@ -10,5 +10,6 @@ module.exports = { rules: { ...configHelpers.getNamingConventionRule(true /* prefixWithI */), 'jsdoc/check-tag-names': 'off', + '@griffel/no-shorthands': 'off', }, };