diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 400887f7..00000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -examples/bundle.js diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index e1f1c1d5..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,11 +0,0 @@ -parser: "@babel/eslint-parser" -extends: - - vkbansal - - vkbansal/react -env: - browser: true -settings: - react: - version: detect -rules: - react/no-array-index-key: 0 diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..138065e6 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,75 @@ +import globals from 'globals'; +import babelParser from '@babel/eslint-parser'; +import jest from 'eslint-plugin-jest'; +import jestDom from 'eslint-plugin-jest-dom'; +import testingLibrary from 'eslint-plugin-testing-library'; +import { FlatCompat } from '@eslint/eslintrc'; + +// Useful function tool to more easily merge external shared configuration for a +// specific files filter. +function configsForFiles({ files, configs }) { + return configs.map(config => ({ ...config, files })); +} + +// Useful to import legacy shared configuration +const compat = new FlatCompat(); + +export default [ + ...compat.extends('vkbansal', 'vkbansal/react'), + { + languageOptions: { + parser: babelParser, + globals: { + ...globals.browser + } + }, + rules: { + 'react/no-array-index-key': 'off' + }, + settings: { + react: { + version: 'detect' + } + } + }, + ...configsForFiles({ + files: ['**/tests/*.js'], + configs: [ + jest.configs['flat/recommended'], + jestDom.configs['flat/recommended'], + testingLibrary.configs['flat/react'], + { + rules: { + 'prefer-arrow-callback': 'off', + 'no-mixed-requires': 'off', + // This disallows using direct Node properties (eg: firstChild), but we + // have legitimate uses: + 'testing-library/no-node-access': 'off', + 'import/no-extraneous-dependencies': [ + 'error', + { devDependencies: true } + ] + } + } + ] + }), + { + files: ['**/examples/*.js'], + settings: { + 'import/resolver': { + webpack: { + config: 'examples/webpack.config.js' + } + } + }, + rules: { + 'import/no-extraneous-dependencies': ['error', { devDependencies: true }] + } + }, + { + files: ['eslint.config.mjs'], + rules: { + 'import/no-extraneous-dependencies': ['error', { devDependencies: true }] + } + } +]; diff --git a/examples/.eslintrc.yml b/examples/.eslintrc.yml deleted file mode 100644 index 504d133d..00000000 --- a/examples/.eslintrc.yml +++ /dev/null @@ -1,6 +0,0 @@ -settings: - import/resolver: - webpack: - config: examples/webpack.config.js -rules: - import/no-extraneous-dependencies: off diff --git a/package.json b/package.json index 005e7da0..79d4bbb3 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@babel/preset-env": "^7.26.7", "@babel/preset-react": "^7.26.3", "@babel/preset-stage-2": "^7.8.3", + "@eslint/eslintrc": "^3.3.0", "@testing-library/dom": "^10.4.0", "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.2.0", @@ -76,6 +77,7 @@ "eslint-plugin-jest-dom": "^5.5.0", "eslint-plugin-react": "~7.37.4", "eslint-plugin-testing-library": "^7.1.1", + "globals": "^16.0.0", "history": "~5.3.0", "html-webpack-plugin": "~5.6.3", "jest": "~29.7.0", diff --git a/tests/.eslintrc.yml b/tests/.eslintrc.yml deleted file mode 100644 index aabe1783..00000000 --- a/tests/.eslintrc.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -plugins: - - jest - - jest-dom - - testing-library -extends: - - plugin:jest/recommended - - plugin:jest-dom/recommended - - plugin:testing-library/react -env: - jest: true -rules: - prefer-arrow-callback: 0 - no-mixed-requires: 0 - # This disallows using direct Node properties (eg: firstChild), but we have - # legitimate uses: - testing-library/no-node-access: 0 diff --git a/tests/.setup.js b/tests/.setup.js index 4bdf2145..8ee6c268 100644 --- a/tests/.setup.js +++ b/tests/.setup.js @@ -3,6 +3,6 @@ import '@testing-library/jest-dom'; window.resizeTo = (width, height) => { window.innerWidth = width || window.innerWidth; - window.innerHeight = width || window.innerHeight; + window.innerHeight = height || window.innerHeight; window.dispatchEvent(new Event('resize')); }; diff --git a/yarn.lock b/yarn.lock index 42b59fcb..cb552e4d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1003,6 +1003,21 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" +"@eslint/eslintrc@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.3.0.tgz#96a558f45842989cca7ea1ecd785ad5491193846" + integrity sha512-yaVPAiNAalnCZedKLdR21GOGILMLKPyqSLWaAjQFvYA2i/ciDi8ArYVr69Anohb6cH2Ukhqti4aFnYyPm8wdwQ== + dependencies: + ajv "^6.12.4" + debug "^4.3.2" + espree "^10.0.1" + globals "^14.0.0" + ignore "^5.2.0" + import-fresh "^3.2.1" + js-yaml "^4.1.0" + minimatch "^3.1.2" + strip-json-comments "^3.1.1" + "@eslint/js@8.57.1": version "8.57.1" resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.1.tgz#de633db3ec2ef6a3c89e2f19038063e8a122e2c2" @@ -3347,6 +3362,15 @@ eslint@~8.57.1: strip-ansi "^6.0.1" text-table "^0.2.0" +espree@^10.0.1: + version "10.3.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-10.3.0.tgz#29267cf5b0cb98735b65e64ba07e0ed49d1eed8a" + integrity sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg== + dependencies: + acorn "^8.14.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^4.2.0" + espree@^9.6.0, espree@^9.6.1: version "9.6.1" resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" @@ -3790,6 +3814,16 @@ globals@^13.19.0: dependencies: type-fest "^0.20.2" +globals@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" + integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== + +globals@^16.0.0: + version "16.0.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-16.0.0.tgz#3d7684652c5c4fbd086ec82f9448214da49382d8" + integrity sha512-iInW14XItCXET01CQFqudPOWP2jYMl7T+QRQT+UNcR/iQncN/F0UNpgd76iFkBPgNQb4+X3LV9tLJYzwh+Gl3A== + globalthis@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.4.tgz#7430ed3a975d97bfb59bcce41f5cabbafa651236" @@ -6375,7 +6409,16 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -6466,7 +6509,14 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -7066,7 +7116,16 @@ word-wrap@~1.2.3: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f" integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==