diff --git a/package.json b/package.json index 502187b3..edf1f527 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "eslint-plugin-jsdoc": "~36.1.0", "eslint-plugin-prettier": "~4.0.0", "eslint-plugin-spellcheck": "~0.0.19", + "eslint-plugin-unicorn": "~36.0.0", "eslint-plugin-vue": "~7.18.0", "esno": "~0.10.0", "json-schema-to-typescript": "~10.1.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0de7ed7a..11ec1258 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,6 +13,7 @@ specifiers: eslint-plugin-jsdoc: ~36.1.0 eslint-plugin-prettier: ~4.0.0 eslint-plugin-spellcheck: ~0.0.19 + eslint-plugin-unicorn: ~36.0.0 eslint-plugin-vue: ~7.18.0 esno: ~0.10.0 json-schema-to-typescript: ~10.1.5 @@ -35,6 +36,7 @@ devDependencies: eslint-plugin-jsdoc: 36.1.0_eslint@7.32.0 eslint-plugin-prettier: 4.0.0_6e975bd57c7acf028c1a9ddbbf60c898 eslint-plugin-spellcheck: 0.0.19_eslint@7.32.0 + eslint-plugin-unicorn: 36.0.0_eslint@7.32.0 eslint-plugin-vue: 7.18.0_eslint@7.32.0 esno: 0.10.0 json-schema-to-typescript: 10.1.5 @@ -68,11 +70,177 @@ packages: '@babel/highlight': 7.14.5 dev: true + /@babel/compat-data/7.15.0: + resolution: {integrity: sha512-0NqAC1IJE0S0+lL1SWFMxMkz1pKCNCjI4tr2Zx4LJSXxCLAdr6KyArnY+sno5m3yH9g737ygOyPABDsnXkpxiA==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/core/7.15.5: + resolution: {integrity: sha512-pYgXxiwAgQpgM1bNkZsDEq85f0ggXMA5L7c+o3tskGMh2BunCI9QUwB9Z4jpvXUOuMdyGKiGKQiRe11VS6Jzvg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/code-frame': 7.14.5 + '@babel/generator': 7.15.4 + '@babel/helper-compilation-targets': 7.15.4_@babel+core@7.15.5 + '@babel/helper-module-transforms': 7.15.7 + '@babel/helpers': 7.15.4 + '@babel/parser': 7.15.7 + '@babel/template': 7.15.4 + '@babel/traverse': 7.15.4 + '@babel/types': 7.15.6 + convert-source-map: 1.8.0 + debug: 4.3.2 + gensync: 1.0.0-beta.2 + json5: 2.2.0 + semver: 6.3.0 + source-map: 0.5.7 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/eslint-parser/7.15.7_@babel+core@7.15.5+eslint@7.32.0: + resolution: {integrity: sha512-yJkHyomClm6A2Xzb8pdAo4HzYMSXFn1O5zrCYvbFP0yQFvHueLedV8WiEno8yJOKStjUXzBZzJFeWQ7b3YMsqQ==} + engines: {node: ^10.13.0 || ^12.13.0 || >=14.0.0} + peerDependencies: + '@babel/core': '>=7.11.0' + eslint: '>=7.5.0' + dependencies: + '@babel/core': 7.15.5 + eslint: 7.32.0 + eslint-scope: 5.1.1 + eslint-visitor-keys: 2.1.0 + semver: 6.3.0 + dev: true + + /@babel/generator/7.15.4: + resolution: {integrity: sha512-d3itta0tu+UayjEORPNz6e1T3FtvWlP5N4V5M+lhp/CxT4oAA7/NcScnpRyspUMLK6tu9MNHmQHxRykuN2R7hw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.15.6 + jsesc: 2.5.2 + source-map: 0.5.7 + dev: true + + /@babel/helper-compilation-targets/7.15.4_@babel+core@7.15.5: + resolution: {integrity: sha512-rMWPCirulnPSe4d+gwdWXLfAXTTBj8M3guAf5xFQJ0nvFY7tfNAFnWdqaHegHlgDZOCT4qvhF3BYlSJag8yhqQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + dependencies: + '@babel/compat-data': 7.15.0 + '@babel/core': 7.15.5 + '@babel/helper-validator-option': 7.14.5 + browserslist: 4.17.2 + semver: 6.3.0 + dev: true + + /@babel/helper-function-name/7.15.4: + resolution: {integrity: sha512-Z91cOMM4DseLIGOnog+Z8OI6YseR9bua+HpvLAQ2XayUGU+neTtX+97caALaLdyu53I/fjhbeCnWnRH1O3jFOw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-get-function-arity': 7.15.4 + '@babel/template': 7.15.4 + '@babel/types': 7.15.6 + dev: true + + /@babel/helper-get-function-arity/7.15.4: + resolution: {integrity: sha512-1/AlxSF92CmGZzHnC515hm4SirTxtpDnLEJ0UyEMgTMZN+6bxXKg04dKhiRx5Enel+SUA1G1t5Ed/yQia0efrA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.15.6 + dev: true + + /@babel/helper-hoist-variables/7.15.4: + resolution: {integrity: sha512-VTy085egb3jUGVK9ycIxQiPbquesq0HUQ+tPO0uv5mPEBZipk+5FkRKiWq5apuyTE9FUrjENB0rCf8y+n+UuhA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.15.6 + dev: true + + /@babel/helper-member-expression-to-functions/7.15.4: + resolution: {integrity: sha512-cokOMkxC/BTyNP1AlY25HuBWM32iCEsLPI4BHDpJCHHm1FU2E7dKWWIXJgQgSFiu4lp8q3bL1BIKwqkSUviqtA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.15.6 + dev: true + + /@babel/helper-module-imports/7.15.4: + resolution: {integrity: sha512-jeAHZbzUwdW/xHgHQ3QmWR4Jg6j15q4w/gCfwZvtqOxoo5DKtLHk8Bsf4c5RZRC7NmLEs+ohkdq8jFefuvIxAA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.15.6 + dev: true + + /@babel/helper-module-transforms/7.15.7: + resolution: {integrity: sha512-ZNqjjQG/AuFfekFTY+7nY4RgBSklgTu970c7Rj3m/JOhIu5KPBUuTA9AY6zaKcUvk4g6EbDXdBnhi35FAssdSw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-module-imports': 7.15.4 + '@babel/helper-replace-supers': 7.15.4 + '@babel/helper-simple-access': 7.15.4 + '@babel/helper-split-export-declaration': 7.15.4 + '@babel/helper-validator-identifier': 7.15.7 + '@babel/template': 7.15.4 + '@babel/traverse': 7.15.4 + '@babel/types': 7.15.6 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/helper-optimise-call-expression/7.15.4: + resolution: {integrity: sha512-E/z9rfbAOt1vDW1DR7k4SzhzotVV5+qMciWV6LaG1g4jeFrkDlJedjtV4h0i4Q/ITnUu+Pk08M7fczsB9GXBDw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.15.6 + dev: true + + /@babel/helper-replace-supers/7.15.4: + resolution: {integrity: sha512-/ztT6khaXF37MS47fufrKvIsiQkx1LBRvSJNzRqmbyeZnTwU9qBxXYLaaT/6KaxfKhjs2Wy8kG8ZdsFUuWBjzw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-member-expression-to-functions': 7.15.4 + '@babel/helper-optimise-call-expression': 7.15.4 + '@babel/traverse': 7.15.4 + '@babel/types': 7.15.6 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/helper-simple-access/7.15.4: + resolution: {integrity: sha512-UzazrDoIVOZZcTeHHEPYrr1MvTR/K+wgLg6MY6e1CJyaRhbibftF6fR2KU2sFRtI/nERUZR9fBd6aKgBlIBaPg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.15.6 + dev: true + + /@babel/helper-split-export-declaration/7.15.4: + resolution: {integrity: sha512-HsFqhLDZ08DxCpBdEVtKmywj6PQbwnF6HHybur0MAnkAKnlS6uHkwnmRIkElB2Owpfb4xL4NwDmDLFubueDXsw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.15.6 + dev: true + /@babel/helper-validator-identifier/7.15.7: resolution: {integrity: sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==} engines: {node: '>=6.9.0'} dev: true + /@babel/helper-validator-option/7.14.5: + resolution: {integrity: sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/helpers/7.15.4: + resolution: {integrity: sha512-V45u6dqEJ3w2rlryYYXf6i9rQ5YMNu4FLS6ngs8ikblhu2VdR1AqAd6aJjBzmf2Qzh6KOLqKHxEN9+TFbAkAVQ==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/template': 7.15.4 + '@babel/traverse': 7.15.4 + '@babel/types': 7.15.6 + transitivePeerDependencies: + - supports-color + dev: true + /@babel/highlight/7.14.5: resolution: {integrity: sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==} engines: {node: '>=6.9.0'} @@ -82,6 +250,46 @@ packages: js-tokens: 4.0.0 dev: true + /@babel/parser/7.15.7: + resolution: {integrity: sha512-rycZXvQ+xS9QyIcJ9HXeDWf1uxqlbVFAUq0Rq0dbc50Zb/+wUe/ehyfzGfm9KZZF0kBejYgxltBXocP+gKdL2g==} + engines: {node: '>=6.0.0'} + hasBin: true + dev: true + + /@babel/template/7.15.4: + resolution: {integrity: sha512-UgBAfEa1oGuYgDIPM2G+aHa4Nlo9Lh6mGD2bDBGMTbYnc38vulXPuC1MGjYILIEmlwl6Rd+BPR9ee3gm20CBtg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/code-frame': 7.14.5 + '@babel/parser': 7.15.7 + '@babel/types': 7.15.6 + dev: true + + /@babel/traverse/7.15.4: + resolution: {integrity: sha512-W6lQD8l4rUbQR/vYgSuCAE75ADyyQvOpFVsvPPdkhf6lATXAsQIG9YdtOcu8BB1dZ0LKu+Zo3c1wEcbKeuhdlA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/code-frame': 7.14.5 + '@babel/generator': 7.15.4 + '@babel/helper-function-name': 7.15.4 + '@babel/helper-hoist-variables': 7.15.4 + '@babel/helper-split-export-declaration': 7.15.4 + '@babel/parser': 7.15.7 + '@babel/types': 7.15.6 + debug: 4.3.2 + globals: 11.12.0 + transitivePeerDependencies: + - supports-color + dev: true + + /@babel/types/7.15.6: + resolution: {integrity: sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-validator-identifier': 7.15.7 + to-fast-properties: 2.0.0 + dev: true + /@es-joy/jsdoccomment/0.10.8: resolution: {integrity: sha512-3P1JiGL4xaR9PoTKUHa2N/LKwa2/eUdRqGwijMWWgBqbFEqJUVpmaOi2TcjcemrsRMgFLBzQCK4ToPhrSVDiFQ==} engines: {node: ^12 || ^14 || ^16} @@ -562,6 +770,23 @@ packages: fill-range: 7.0.1 dev: true + /browserslist/4.17.2: + resolution: {integrity: sha512-jSDZyqJmkKMEMi7SZAgX5UltFdR5NAO43vY0AwTpu4X3sGH7GLLQ83KiUomgrnvZRCeW0yPPnKqnxPqQOER9zQ==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + dependencies: + caniuse-lite: 1.0.30001263 + electron-to-chromium: 1.3.856 + escalade: 3.1.1 + nanocolors: 0.2.12 + node-releases: 1.1.76 + dev: true + + /builtin-modules/3.2.0: + resolution: {integrity: sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==} + engines: {node: '>=6'} + dev: true + /builtins/1.0.3: resolution: {integrity: sha1-y5T662HIaWRR2zZTThQi+U8K7og=} dev: true @@ -635,6 +860,10 @@ packages: engines: {node: '>=10'} dev: true + /caniuse-lite/1.0.30001263: + resolution: {integrity: sha512-doiV5dft6yzWO1WwU19kt8Qz8R0/8DgEziz6/9n2FxUasteZNwNNYSmJO3GLBH8lCVE73AB1RPDPAeYbcO5Cvw==} + dev: true + /capital-case/1.0.4: resolution: {integrity: sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A==} dependencies: @@ -696,6 +925,17 @@ packages: resolution: {integrity: sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==} dev: true + /ci-info/3.2.0: + resolution: {integrity: sha512-dVqRX7fLUm8J6FgHJ418XuIgDLZDkYcDFTeL6TA2gt5WlIZUQrrH6EZrNClwT/H0FateUsZkGIOPRrLbP+PR9A==} + dev: true + + /clean-regexp/1.0.0: + resolution: {integrity: sha1-jffHquUf02h06PjQW5GAvBGj/tc=} + engines: {node: '>=4'} + dependencies: + escape-string-regexp: 1.0.5 + dev: true + /clean-stack/2.2.0: resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==} engines: {node: '>=6'} @@ -809,6 +1049,12 @@ packages: upper-case: 2.0.2 dev: true + /convert-source-map/1.8.0: + resolution: {integrity: sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==} + dependencies: + safe-buffer: 5.1.2 + dev: true + /cosmiconfig/7.0.1: resolution: {integrity: sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==} engines: {node: '>=10'} @@ -955,6 +1201,10 @@ packages: resolution: {integrity: sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=} dev: true + /electron-to-chromium/1.3.856: + resolution: {integrity: sha512-lSezYIe1/p5qkEswAfaQUseOBiwGwuCvRl/MKzOEVe++DcmQ92+43dznDl4rFJ4Zpu+kevhwyIf7KjJevyDA/A==} + dev: true + /elegant-spinner/1.0.1: resolution: {integrity: sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4=} engines: {node: '>=0.10.0'} @@ -1181,6 +1431,11 @@ packages: esbuild-windows-arm64: 0.13.3 dev: true + /escalade/3.1.1: + resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} + engines: {node: '>=6'} + dev: true + /escape-goat/2.1.1: resolution: {integrity: sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q==} engines: {node: '>=8'} @@ -1264,6 +1519,29 @@ packages: lodash: 4.17.21 dev: true + /eslint-plugin-unicorn/36.0.0_eslint@7.32.0: + resolution: {integrity: sha512-xxN2vSctGWnDW6aLElm/LKIwcrmk6mdiEcW55Uv5krcrVcIFSWMmEgc/hwpemYfZacKZ5npFERGNz4aThsp1AA==} + engines: {node: '>=12'} + peerDependencies: + eslint: '>=7.32.0' + dependencies: + '@babel/helper-validator-identifier': 7.15.7 + ci-info: 3.2.0 + clean-regexp: 1.0.0 + eslint: 7.32.0 + eslint-template-visitor: 2.3.2_eslint@7.32.0 + eslint-utils: 3.0.0_eslint@7.32.0 + is-builtin-module: 3.1.0 + lodash: 4.17.21 + pluralize: 8.0.0 + read-pkg-up: 7.0.1 + regexp-tree: 0.1.24 + safe-regex: 2.1.1 + semver: 7.3.5 + transitivePeerDependencies: + - supports-color + dev: true + /eslint-plugin-vue/7.18.0_eslint@7.32.0: resolution: {integrity: sha512-ceDXlXYMMPMSXw7tdKUR42w9jlzthJGJ3Kvm3YrZ0zuQfvAySNxe8sm6VHuksBW0+060GzYXhHJG6IHVOfF83Q==} engines: {node: '>=8.10'} @@ -1287,6 +1565,21 @@ packages: estraverse: 4.3.0 dev: true + /eslint-template-visitor/2.3.2_eslint@7.32.0: + resolution: {integrity: sha512-3ydhqFpuV7x1M9EK52BPNj6V0Kwu0KKkcIAfpUhwHbR8ocRln/oUHgfxQupY8O1h4Qv/POHDumb/BwwNfxbtnA==} + peerDependencies: + eslint: '>=7.0.0' + dependencies: + '@babel/core': 7.15.5 + '@babel/eslint-parser': 7.15.7_@babel+core@7.15.5+eslint@7.32.0 + eslint: 7.32.0 + eslint-visitor-keys: 2.1.0 + esquery: 1.4.0 + multimap: 1.1.0 + transitivePeerDependencies: + - supports-color + dev: true + /eslint-utils/2.1.0: resolution: {integrity: sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==} engines: {node: '>=6'} @@ -1572,6 +1865,11 @@ packages: resolution: {integrity: sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=} dev: true + /gensync/1.0.0-beta.2: + resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} + engines: {node: '>=6.9.0'} + dev: true + /get-stdin/8.0.0: resolution: {integrity: sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==} engines: {node: '>=10'} @@ -1642,6 +1940,11 @@ packages: ini: 2.0.0 dev: true + /globals/11.12.0: + resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} + engines: {node: '>=4'} + dev: true + /globals/13.11.0: resolution: {integrity: sha512-08/xrJ7wQjK9kkkRoI3OFUBbLx4f+6x3SGwcPvQ0QH6goFDrOU2oyAWrmh3dJezu65buo+HBMzAMQy6rovVC3g==} engines: {node: '>=8'} @@ -1914,6 +2217,13 @@ packages: resolution: {integrity: sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=} dev: true + /is-builtin-module/3.1.0: + resolution: {integrity: sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg==} + engines: {node: '>=6'} + dependencies: + builtin-modules: 3.2.0 + dev: true + /is-ci/2.0.0: resolution: {integrity: sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==} hasBin: true @@ -2099,6 +2409,12 @@ packages: engines: {node: '>=12.0.0'} dev: true + /jsesc/2.5.2: + resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==} + engines: {node: '>=4'} + hasBin: true + dev: true + /json-buffer/3.0.0: resolution: {integrity: sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=} dev: true @@ -2156,6 +2472,14 @@ packages: resolution: {integrity: sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=} dev: true + /json5/2.2.0: + resolution: {integrity: sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==} + engines: {node: '>=6'} + hasBin: true + dependencies: + minimist: 1.2.5 + dev: true + /jsonc-parser/3.0.0: resolution: {integrity: sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==} dev: true @@ -2476,6 +2800,10 @@ packages: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: true + /multimap/1.1.0: + resolution: {integrity: sha512-0ZIR9PasPxGXmRsEF8jsDzndzHDj7tIav+JUmvIFB/WHswliFnquxECT/De7GR4yg99ky/NlRKJT82G1y271bw==} + dev: true + /mute-stream/0.0.7: resolution: {integrity: sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=} dev: true @@ -2492,6 +2820,10 @@ packages: thenify-all: 1.6.0 dev: true + /nanocolors/0.2.12: + resolution: {integrity: sha512-SFNdALvzW+rVlzqexid6epYdt8H9Zol7xDoQarioEFcFN0JHo4CYNztAxmtfgGTVRCmFlEOqqhBpoFGKqSAMug==} + dev: true + /natural-compare/1.4.0: resolution: {integrity: sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=} dev: true @@ -2518,6 +2850,10 @@ packages: tslib: 2.3.1 dev: true + /node-releases/1.1.76: + resolution: {integrity: sha512-9/IECtNr8dXNmPWmFXepT0/7o5eolGesHUa3mtr0KlgnCvnZxwh2qensKL42JJY2vQKC3nIBXetFAqR+PW1CmA==} + dev: true + /normalize-package-data/2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} dependencies: @@ -2879,6 +3215,11 @@ packages: find-up: 5.0.0 dev: true + /pluralize/8.0.0: + resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} + engines: {node: '>=4'} + dev: true + /prelude-ls/1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -2982,6 +3323,11 @@ packages: strip-indent: 3.0.0 dev: true + /regexp-tree/0.1.24: + resolution: {integrity: sha512-s2aEVuLhvnVJW6s/iPgEGK6R+/xngd2jNQ+xy4bXNDKxZKJH6jpPHY6kVeVv1IeLCHgswRj+Kl3ELaDjG6V1iw==} + hasBin: true + dev: true + /regexpp/3.2.0: resolution: {integrity: sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==} engines: {node: '>=8'} @@ -3093,6 +3439,16 @@ packages: tslib: 1.14.1 dev: true + /safe-buffer/5.1.2: + resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} + dev: true + + /safe-regex/2.1.1: + resolution: {integrity: sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==} + dependencies: + regexp-tree: 0.1.24 + dev: true + /safer-buffer/2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} dev: true @@ -3177,6 +3533,11 @@ packages: tslib: 2.3.1 dev: true + /source-map/0.5.7: + resolution: {integrity: sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=} + engines: {node: '>=0.10.0'} + dev: true + /spdx-correct/3.1.1: resolution: {integrity: sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==} dependencies: @@ -3377,6 +3738,11 @@ packages: os-tmpdir: 1.0.2 dev: true + /to-fast-properties/2.0.0: + resolution: {integrity: sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=} + engines: {node: '>=4'} + dev: true + /to-readable-stream/1.0.0: resolution: {integrity: sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==} engines: {node: '>=6'} diff --git a/scripts/generate-rule-files.ts b/scripts/generate-rule-files.ts index 3b259e16..dfce30f0 100644 --- a/scripts/generate-rule-files.ts +++ b/scripts/generate-rule-files.ts @@ -8,6 +8,8 @@ import eslintPluginJSDoc from 'eslint-plugin-jsdoc'; // @ts-expect-error import eslintPluginSpellcheck from 'eslint-plugin-spellcheck'; // @ts-expect-error +import eslintPluginUnicorn from 'eslint-plugin-unicorn'; +// @ts-expect-error import eslintPluginVue from 'eslint-plugin-vue'; import * as fs from 'fs'; import type { JSONSchema4 } from 'json-schema'; @@ -40,6 +42,11 @@ const generationMap: Record = { name: 'Eslint', rules: Object.fromEntries(new eslint.Linter().getRules().entries()) }, + 'typescript-eslint': { + name: 'TypeScript', + prefix: '@typescript-eslint', + rules: (eslintPluginTypeScript as Plugin).rules + }, jsdoc: { name: 'JSDoc', rules: (eslintPluginJSDoc as Plugin).rules @@ -48,10 +55,9 @@ const generationMap: Record = { name: 'Spellcheck', rules: (eslintPluginSpellcheck as Plugin).rules }, - 'typescript-eslint': { - name: 'TypeScript', - prefix: '@typescript-eslint', - rules: (eslintPluginTypeScript as Plugin).rules + unicorn: { + name: 'Unicorn', + rules: (eslintPluginUnicorn as Plugin).rules }, vue: { name: 'Vue', diff --git a/src/extends/eslint-plugin-unicorn.d.ts b/src/extends/eslint-plugin-unicorn.d.ts new file mode 100644 index 00000000..44e3331f --- /dev/null +++ b/src/extends/eslint-plugin-unicorn.d.ts @@ -0,0 +1,6 @@ +/** + * Eslint Unicorn extensions. + * + * @see [Eslint Unicorn extensions](https://github.com/sindresorhus/eslint-plugin-unicorn) + */ +export type UnicornExtensions = 'plugin:unicorn/recommended' | 'plugin:unicorn/all'; diff --git a/src/extends/index.d.ts b/src/extends/index.d.ts index 93137b85..be4853c7 100644 --- a/src/extends/index.d.ts +++ b/src/extends/index.d.ts @@ -4,6 +4,7 @@ import type { ImportExtensions } from './eslint-plugin-import'; import type { JsdocExtensions } from './eslint-plugin-jsdoc'; import type { NodeExtensions } from './eslint-plugin-node'; import type { PrettierExtensions } from './eslint-plugin-prettier'; +import type { UnicornExtensions } from './eslint-plugin-unicorn'; import type { VueExtensions } from './eslint-plugin-vue'; import type { TypescriptEslintExtensions } from './typescript-eslint'; @@ -12,11 +13,12 @@ import type { TypescriptEslintExtensions } from './typescript-eslint'; */ export type KnownExtensions = LiteralUnion< | EslintExtensions - | TypescriptEslintExtensions - | PrettierExtensions - | NodeExtensions | ImportExtensions | JsdocExtensions + | NodeExtensions + | PrettierExtensions + | TypescriptEslintExtensions + | UnicornExtensions | VueExtensions >; diff --git a/src/plugin.d.ts b/src/plugin.d.ts index 08d7c05d..5ab2fbb8 100644 --- a/src/plugin.d.ts +++ b/src/plugin.d.ts @@ -2,5 +2,5 @@ import type { LiteralUnion } from './utility-types'; /** Plugin. */ export type Plugin = LiteralUnion< - '@typescript-eslint' | 'prettier' | 'import' | 'jsdoc' | 'spellcheck' | 'inclusive-language' + '@typescript-eslint' | 'import' | 'inclusive-language' | 'jsdoc' | 'prettier' | 'spellcheck' | 'unicorn' | 'vue' >; diff --git a/src/rules/index.d.ts b/src/rules/index.d.ts index f7232da5..355bf6d0 100644 --- a/src/rules/index.d.ts +++ b/src/rules/index.d.ts @@ -5,6 +5,7 @@ import type { NodeRules } from './node'; import type { RuleConfig } from './rule-config'; import type { SpellcheckRules } from './spellcheck'; import type { TypeScriptRules } from './typescript-eslint'; +import type { UnicornRules } from './unicorn'; import type { VueRules } from './vue'; /** @@ -14,11 +15,12 @@ import type { VueRules } from './vue'; */ export type Rules = Partial< EslintRules & - TypeScriptRules & - NodeRules & ImportRules & JSDocRules & + NodeRules & SpellcheckRules & + TypeScriptRules & + UnicornRules & VueRules & Record >; diff --git a/src/rules/unicorn/better-regex.d.ts b/src/rules/unicorn/better-regex.d.ts new file mode 100644 index 00000000..120fdf65 --- /dev/null +++ b/src/rules/unicorn/better-regex.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface BetterRegexOption { + sortCharacterClasses?: boolean; + [k: string]: any; +} + +/** + * Options. + */ +export type BetterRegexOptions = [BetterRegexOption?]; + +/** + * Improve regexes by making them shorter, consistent, and safer. + * + * @see [better-regex](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/better-regex.md) + */ +export type BetterRegexRuleConfig = RuleConfig; + +/** + * Improve regexes by making them shorter, consistent, and safer. + * + * @see [better-regex](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/better-regex.md) + */ +export interface BetterRegexRule { + /** + * Improve regexes by making them shorter, consistent, and safer. + * + * @see [better-regex](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/better-regex.md) + */ + 'unicorn/better-regex': BetterRegexRuleConfig; +} diff --git a/src/rules/unicorn/catch-error-name.d.ts b/src/rules/unicorn/catch-error-name.d.ts new file mode 100644 index 00000000..8430f386 --- /dev/null +++ b/src/rules/unicorn/catch-error-name.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface CatchErrorNameOption { + name?: string; + ignore?: any[]; + [k: string]: any; +} + +/** + * Options. + */ +export type CatchErrorNameOptions = [CatchErrorNameOption?]; + +/** + * Enforce a specific parameter name in catch clauses. + * + * @see [catch-error-name](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/catch-error-name.md) + */ +export type CatchErrorNameRuleConfig = RuleConfig; + +/** + * Enforce a specific parameter name in catch clauses. + * + * @see [catch-error-name](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/catch-error-name.md) + */ +export interface CatchErrorNameRule { + /** + * Enforce a specific parameter name in catch clauses. + * + * @see [catch-error-name](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/catch-error-name.md) + */ + 'unicorn/catch-error-name': CatchErrorNameRuleConfig; +} diff --git a/src/rules/unicorn/consistent-destructuring.d.ts b/src/rules/unicorn/consistent-destructuring.d.ts new file mode 100644 index 00000000..753d1cbc --- /dev/null +++ b/src/rules/unicorn/consistent-destructuring.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Use destructured variables over properties. + * + * @see [consistent-destructuring](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/consistent-destructuring.md) + */ +export type ConsistentDestructuringRuleConfig = RuleConfig<[]>; + +/** + * Use destructured variables over properties. + * + * @see [consistent-destructuring](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/consistent-destructuring.md) + */ +export interface ConsistentDestructuringRule { + /** + * Use destructured variables over properties. + * + * @see [consistent-destructuring](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/consistent-destructuring.md) + */ + 'unicorn/consistent-destructuring': ConsistentDestructuringRuleConfig; +} diff --git a/src/rules/unicorn/consistent-function-scoping.d.ts b/src/rules/unicorn/consistent-function-scoping.d.ts new file mode 100644 index 00000000..4f56b560 --- /dev/null +++ b/src/rules/unicorn/consistent-function-scoping.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ConsistentFunctionScopingOption { + checkArrowFunctions?: boolean; + [k: string]: any; +} + +/** + * Options. + */ +export type ConsistentFunctionScopingOptions = [ConsistentFunctionScopingOption?]; + +/** + * Move function definitions to the highest possible scope. + * + * @see [consistent-function-scoping](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/consistent-function-scoping.md) + */ +export type ConsistentFunctionScopingRuleConfig = RuleConfig; + +/** + * Move function definitions to the highest possible scope. + * + * @see [consistent-function-scoping](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/consistent-function-scoping.md) + */ +export interface ConsistentFunctionScopingRule { + /** + * Move function definitions to the highest possible scope. + * + * @see [consistent-function-scoping](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/consistent-function-scoping.md) + */ + 'unicorn/consistent-function-scoping': ConsistentFunctionScopingRuleConfig; +} diff --git a/src/rules/unicorn/custom-error-definition.d.ts b/src/rules/unicorn/custom-error-definition.d.ts new file mode 100644 index 00000000..6e1c362d --- /dev/null +++ b/src/rules/unicorn/custom-error-definition.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce correct `Error` subclassing. + * + * @see [custom-error-definition](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/custom-error-definition.md) + */ +export type CustomErrorDefinitionRuleConfig = RuleConfig<[]>; + +/** + * Enforce correct `Error` subclassing. + * + * @see [custom-error-definition](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/custom-error-definition.md) + */ +export interface CustomErrorDefinitionRule { + /** + * Enforce correct `Error` subclassing. + * + * @see [custom-error-definition](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/custom-error-definition.md) + */ + 'unicorn/custom-error-definition': CustomErrorDefinitionRuleConfig; +} diff --git a/src/rules/unicorn/empty-brace-spaces.d.ts b/src/rules/unicorn/empty-brace-spaces.d.ts new file mode 100644 index 00000000..4be13e10 --- /dev/null +++ b/src/rules/unicorn/empty-brace-spaces.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce no spaces between braces. + * + * @see [empty-brace-spaces](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/empty-brace-spaces.md) + */ +export type EmptyBraceSpacesRuleConfig = RuleConfig<[]>; + +/** + * Enforce no spaces between braces. + * + * @see [empty-brace-spaces](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/empty-brace-spaces.md) + */ +export interface EmptyBraceSpacesRule { + /** + * Enforce no spaces between braces. + * + * @see [empty-brace-spaces](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/empty-brace-spaces.md) + */ + 'unicorn/empty-brace-spaces': EmptyBraceSpacesRuleConfig; +} diff --git a/src/rules/unicorn/error-message.d.ts b/src/rules/unicorn/error-message.d.ts new file mode 100644 index 00000000..a102a2b3 --- /dev/null +++ b/src/rules/unicorn/error-message.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce passing a `message` value when creating a built-in error. + * + * @see [error-message](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/error-message.md) + */ +export type ErrorMessageRuleConfig = RuleConfig<[]>; + +/** + * Enforce passing a `message` value when creating a built-in error. + * + * @see [error-message](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/error-message.md) + */ +export interface ErrorMessageRule { + /** + * Enforce passing a `message` value when creating a built-in error. + * + * @see [error-message](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/error-message.md) + */ + 'unicorn/error-message': ErrorMessageRuleConfig; +} diff --git a/src/rules/unicorn/escape-case.d.ts b/src/rules/unicorn/escape-case.d.ts new file mode 100644 index 00000000..eafa630b --- /dev/null +++ b/src/rules/unicorn/escape-case.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Require escape sequences to use uppercase values. + * + * @see [escape-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/escape-case.md) + */ +export type EscapeCaseRuleConfig = RuleConfig<[]>; + +/** + * Require escape sequences to use uppercase values. + * + * @see [escape-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/escape-case.md) + */ +export interface EscapeCaseRule { + /** + * Require escape sequences to use uppercase values. + * + * @see [escape-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/escape-case.md) + */ + 'unicorn/escape-case': EscapeCaseRuleConfig; +} diff --git a/src/rules/unicorn/expiring-todo-comments.d.ts b/src/rules/unicorn/expiring-todo-comments.d.ts new file mode 100644 index 00000000..c08a9ce1 --- /dev/null +++ b/src/rules/unicorn/expiring-todo-comments.d.ts @@ -0,0 +1,37 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ExpiringTodoCommentsOption { + terms?: string[]; + ignore?: any[]; + ignoreDatesOnPullRequests?: boolean; + allowWarningComments?: boolean; +} + +/** + * Options. + */ +export type ExpiringTodoCommentsOptions = [ExpiringTodoCommentsOption?]; + +/** + * Add expiration conditions to TODO comments. + * + * @see [expiring-todo-comments](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/expiring-todo-comments.md) + */ +export type ExpiringTodoCommentsRuleConfig = RuleConfig; + +/** + * Add expiration conditions to TODO comments. + * + * @see [expiring-todo-comments](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/expiring-todo-comments.md) + */ +export interface ExpiringTodoCommentsRule { + /** + * Add expiration conditions to TODO comments. + * + * @see [expiring-todo-comments](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/expiring-todo-comments.md) + */ + 'unicorn/expiring-todo-comments': ExpiringTodoCommentsRuleConfig; +} diff --git a/src/rules/unicorn/explicit-length-check.d.ts b/src/rules/unicorn/explicit-length-check.d.ts new file mode 100644 index 00000000..cb116966 --- /dev/null +++ b/src/rules/unicorn/explicit-length-check.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ExplicitLengthCheckOption { + 'non-zero'?: 'greater-than' | 'not-equal'; + [k: string]: any; +} + +/** + * Options. + */ +export type ExplicitLengthCheckOptions = [ExplicitLengthCheckOption?]; + +/** + * Enforce explicitly comparing the `length` or `size` property of a value. + * + * @see [explicit-length-check](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/explicit-length-check.md) + */ +export type ExplicitLengthCheckRuleConfig = RuleConfig; + +/** + * Enforce explicitly comparing the `length` or `size` property of a value. + * + * @see [explicit-length-check](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/explicit-length-check.md) + */ +export interface ExplicitLengthCheckRule { + /** + * Enforce explicitly comparing the `length` or `size` property of a value. + * + * @see [explicit-length-check](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/explicit-length-check.md) + */ + 'unicorn/explicit-length-check': ExplicitLengthCheckRuleConfig; +} diff --git a/src/rules/unicorn/filename-case.d.ts b/src/rules/unicorn/filename-case.d.ts new file mode 100644 index 00000000..a3c9a223 --- /dev/null +++ b/src/rules/unicorn/filename-case.d.ts @@ -0,0 +1,45 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type FilenameCaseOption = + | { + case?: 'camelCase' | 'snakeCase' | 'kebabCase' | 'pascalCase'; + ignore?: any[]; + } + | { + cases?: { + camelCase?: boolean; + snakeCase?: boolean; + kebabCase?: boolean; + pascalCase?: boolean; + }; + ignore?: any[]; + }; + +/** + * Options. + */ +export type FilenameCaseOptions = [FilenameCaseOption?]; + +/** + * Enforce a case style for filenames. + * + * @see [filename-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/filename-case.md) + */ +export type FilenameCaseRuleConfig = RuleConfig; + +/** + * Enforce a case style for filenames. + * + * @see [filename-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/filename-case.md) + */ +export interface FilenameCaseRule { + /** + * Enforce a case style for filenames. + * + * @see [filename-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/filename-case.md) + */ + 'unicorn/filename-case': FilenameCaseRuleConfig; +} diff --git a/src/rules/unicorn/import-index.d.ts b/src/rules/unicorn/import-index.d.ts new file mode 100644 index 00000000..cb093d19 --- /dev/null +++ b/src/rules/unicorn/import-index.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface ImportIndexOption { + ignoreImports?: boolean; +} + +/** + * Options. + */ +export type ImportIndexOptions = [ImportIndexOption?]; + +/** + * Enforce importing index files with `.`. + * + * @see [import-index](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/import-index.md) + */ +export type ImportIndexRuleConfig = RuleConfig; + +/** + * Enforce importing index files with `.`. + * + * @see [import-index](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/import-index.md) + */ +export interface ImportIndexRule { + /** + * Enforce importing index files with `.`. + * + * @see [import-index](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/import-index.md) + */ + 'unicorn/import-index': ImportIndexRuleConfig; +} diff --git a/src/rules/unicorn/index.d.ts b/src/rules/unicorn/index.d.ts new file mode 100644 index 00000000..c5665ec3 --- /dev/null +++ b/src/rules/unicorn/index.d.ts @@ -0,0 +1,208 @@ +import type { BetterRegexRule } from './better-regex'; +import type { CatchErrorNameRule } from './catch-error-name'; +import type { ConsistentDestructuringRule } from './consistent-destructuring'; +import type { ConsistentFunctionScopingRule } from './consistent-function-scoping'; +import type { CustomErrorDefinitionRule } from './custom-error-definition'; +import type { EmptyBraceSpacesRule } from './empty-brace-spaces'; +import type { ErrorMessageRule } from './error-message'; +import type { EscapeCaseRule } from './escape-case'; +import type { ExpiringTodoCommentsRule } from './expiring-todo-comments'; +import type { ExplicitLengthCheckRule } from './explicit-length-check'; +import type { FilenameCaseRule } from './filename-case'; +import type { ImportIndexRule } from './import-index'; +import type { NewForBuiltinsRule } from './new-for-builtins'; +import type { NoAbusiveEslintDisableRule } from './no-abusive-eslint-disable'; +import type { NoArrayCallbackReferenceRule } from './no-array-callback-reference'; +import type { NoArrayForEachRule } from './no-array-for-each'; +import type { NoArrayMethodThisArgumentRule } from './no-array-method-this-argument'; +import type { NoArrayPushPushRule } from './no-array-push-push'; +import type { NoArrayReduceRule } from './no-array-reduce'; +import type { NoConsoleSpacesRule } from './no-console-spaces'; +import type { NoDocumentCookieRule } from './no-document-cookie'; +import type { NoForLoopRule } from './no-for-loop'; +import type { NoHexEscapeRule } from './no-hex-escape'; +import type { NoInstanceofArrayRule } from './no-instanceof-array'; +import type { NoInvalidRemoveEventListenerRule } from './no-invalid-remove-event-listener'; +import type { NoKeywordPrefixRule } from './no-keyword-prefix'; +import type { NoLonelyIfRule } from './no-lonely-if'; +import type { NoNestedTernaryRule } from './no-nested-ternary'; +import type { NoNewArrayRule } from './no-new-array'; +import type { NoNewBufferRule } from './no-new-buffer'; +import type { NoNullRule } from './no-null'; +import type { NoObjectAsDefaultParameterRule } from './no-object-as-default-parameter'; +import type { NoProcessExitRule } from './no-process-exit'; +import type { NoStaticOnlyClassRule } from './no-static-only-class'; +import type { NoThisAssignmentRule } from './no-this-assignment'; +import type { NoUnreadableArrayDestructuringRule } from './no-unreadable-array-destructuring'; +import type { NoUnsafeRegexRule } from './no-unsafe-regex'; +import type { NoUnusedPropertiesRule } from './no-unused-properties'; +import type { NoUselessFallbackInSpreadRule } from './no-useless-fallback-in-spread'; +import type { NoUselessLengthCheckRule } from './no-useless-length-check'; +import type { NoUselessSpreadRule } from './no-useless-spread'; +import type { NoUselessUndefinedRule } from './no-useless-undefined'; +import type { NoZeroFractionsRule } from './no-zero-fractions'; +import type { NumberLiteralCaseRule } from './number-literal-case'; +import type { NumericSeparatorsStyleRule } from './numeric-separators-style'; +import type { PreferAddEventListenerRule } from './prefer-add-event-listener'; +import type { PreferArrayFindRule } from './prefer-array-find'; +import type { PreferArrayFlatMapRule } from './prefer-array-flat-map'; +import type { PreferArrayFlatRule } from './prefer-array-flat'; +import type { PreferArrayIndexOfRule } from './prefer-array-index-of'; +import type { PreferArraySomeRule } from './prefer-array-some'; +import type { PreferAtRule } from './prefer-at'; +import type { PreferDateNowRule } from './prefer-date-now'; +import type { PreferDefaultParametersRule } from './prefer-default-parameters'; +import type { PreferDomNodeAppendRule } from './prefer-dom-node-append'; +import type { PreferDomNodeDatasetRule } from './prefer-dom-node-dataset'; +import type { PreferDomNodeRemoveRule } from './prefer-dom-node-remove'; +import type { PreferDomNodeTextContentRule } from './prefer-dom-node-text-content'; +import type { PreferIncludesRule } from './prefer-includes'; +import type { PreferKeyboardEventKeyRule } from './prefer-keyboard-event-key'; +import type { PreferMathTruncRule } from './prefer-math-trunc'; +import type { PreferModernDomApisRule } from './prefer-modern-dom-apis'; +import type { PreferModuleRule } from './prefer-module'; +import type { PreferNegativeIndexRule } from './prefer-negative-index'; +import type { PreferNodeProtocolRule } from './prefer-node-protocol'; +import type { PreferNumberPropertiesRule } from './prefer-number-properties'; +import type { PreferObjectFromEntriesRule } from './prefer-object-from-entries'; +import type { PreferObjectHasOwnRule } from './prefer-object-has-own'; +import type { PreferOptionalCatchBindingRule } from './prefer-optional-catch-binding'; +import type { PreferPrototypeMethodsRule } from './prefer-prototype-methods'; +import type { PreferQuerySelectorRule } from './prefer-query-selector'; +import type { PreferReflectApplyRule } from './prefer-reflect-apply'; +import type { PreferRegexpTestRule } from './prefer-regexp-test'; +import type { PreferSetHasRule } from './prefer-set-has'; +import type { PreferSpreadRule } from './prefer-spread'; +import type { PreferStringReplaceAllRule } from './prefer-string-replace-all'; +import type { PreferStringSliceRule } from './prefer-string-slice'; +import type { PreferStringStartsEndsWithRule } from './prefer-string-starts-ends-with'; +import type { PreferStringTrimStartEndRule } from './prefer-string-trim-start-end'; +import type { PreferSwitchRule } from './prefer-switch'; +import type { PreferTernaryRule } from './prefer-ternary'; +import type { PreferTopLevelAwaitRule } from './prefer-top-level-await'; +import type { PreferTypeErrorRule } from './prefer-type-error'; +import type { RequireArrayJoinSeparatorRule } from './require-array-join-separator'; +import type { RequireNumberToFixedDigitsArgumentRule } from './require-number-to-fixed-digits-argument'; +import type { RequirePostMessageTargetOriginRule } from './require-post-message-target-origin'; +import type { StringContentRule } from './string-content'; +import type { ThrowNewErrorRule } from './throw-new-error'; +import type { NoArrayInstanceofRule } from './no-array-instanceof'; +import type { NoFnReferenceInIteratorRule } from './no-fn-reference-in-iterator'; +import type { NoReduceRule } from './no-reduce'; +import type { PreferDatasetRule } from './prefer-dataset'; +import type { PreferEventKeyRule } from './prefer-event-key'; +import type { PreferExponentiationOperatorRule } from './prefer-exponentiation-operator'; +import type { PreferFlatMapRule } from './prefer-flat-map'; +import type { PreferNodeAppendRule } from './prefer-node-append'; +import type { PreferNodeRemoveRule } from './prefer-node-remove'; +import type { PreferReplaceAllRule } from './prefer-replace-all'; +import type { PreferStartsEndsWithRule } from './prefer-starts-ends-with'; +import type { PreferTextContentRule } from './prefer-text-content'; +import type { PreferTrimStartEndRule } from './prefer-trim-start-end'; +import type { RegexShorthandRule } from './regex-shorthand'; + +/** + * All Unicorn rules. + */ +export type UnicornRules = BetterRegexRule & + CatchErrorNameRule & + ConsistentDestructuringRule & + ConsistentFunctionScopingRule & + CustomErrorDefinitionRule & + EmptyBraceSpacesRule & + ErrorMessageRule & + EscapeCaseRule & + ExpiringTodoCommentsRule & + ExplicitLengthCheckRule & + FilenameCaseRule & + ImportIndexRule & + NewForBuiltinsRule & + NoAbusiveEslintDisableRule & + NoArrayCallbackReferenceRule & + NoArrayForEachRule & + NoArrayMethodThisArgumentRule & + NoArrayPushPushRule & + NoArrayReduceRule & + NoConsoleSpacesRule & + NoDocumentCookieRule & + NoForLoopRule & + NoHexEscapeRule & + NoInstanceofArrayRule & + NoInvalidRemoveEventListenerRule & + NoKeywordPrefixRule & + NoLonelyIfRule & + NoNestedTernaryRule & + NoNewArrayRule & + NoNewBufferRule & + NoNullRule & + NoObjectAsDefaultParameterRule & + NoProcessExitRule & + NoStaticOnlyClassRule & + NoThisAssignmentRule & + NoUnreadableArrayDestructuringRule & + NoUnsafeRegexRule & + NoUnusedPropertiesRule & + NoUselessFallbackInSpreadRule & + NoUselessLengthCheckRule & + NoUselessSpreadRule & + NoUselessUndefinedRule & + NoZeroFractionsRule & + NumberLiteralCaseRule & + NumericSeparatorsStyleRule & + PreferAddEventListenerRule & + PreferArrayFindRule & + PreferArrayFlatMapRule & + PreferArrayFlatRule & + PreferArrayIndexOfRule & + PreferArraySomeRule & + PreferAtRule & + PreferDateNowRule & + PreferDefaultParametersRule & + PreferDomNodeAppendRule & + PreferDomNodeDatasetRule & + PreferDomNodeRemoveRule & + PreferDomNodeTextContentRule & + PreferIncludesRule & + PreferKeyboardEventKeyRule & + PreferMathTruncRule & + PreferModernDomApisRule & + PreferModuleRule & + PreferNegativeIndexRule & + PreferNodeProtocolRule & + PreferNumberPropertiesRule & + PreferObjectFromEntriesRule & + PreferObjectHasOwnRule & + PreferOptionalCatchBindingRule & + PreferPrototypeMethodsRule & + PreferQuerySelectorRule & + PreferReflectApplyRule & + PreferRegexpTestRule & + PreferSetHasRule & + PreferSpreadRule & + PreferStringReplaceAllRule & + PreferStringSliceRule & + PreferStringStartsEndsWithRule & + PreferStringTrimStartEndRule & + PreferSwitchRule & + PreferTernaryRule & + PreferTopLevelAwaitRule & + PreferTypeErrorRule & + RequireArrayJoinSeparatorRule & + RequireNumberToFixedDigitsArgumentRule & + RequirePostMessageTargetOriginRule & + StringContentRule & + ThrowNewErrorRule & + NoArrayInstanceofRule & + NoFnReferenceInIteratorRule & + NoReduceRule & + PreferDatasetRule & + PreferEventKeyRule & + PreferExponentiationOperatorRule & + PreferFlatMapRule & + PreferNodeAppendRule & + PreferNodeRemoveRule & + PreferReplaceAllRule & + PreferStartsEndsWithRule & + PreferTextContentRule & + PreferTrimStartEndRule & + RegexShorthandRule; diff --git a/src/rules/unicorn/new-for-builtins.d.ts b/src/rules/unicorn/new-for-builtins.d.ts new file mode 100644 index 00000000..af15999a --- /dev/null +++ b/src/rules/unicorn/new-for-builtins.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. + * + * @see [new-for-builtins](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/new-for-builtins.md) + */ +export type NewForBuiltinsRuleConfig = RuleConfig<[]>; + +/** + * Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. + * + * @see [new-for-builtins](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/new-for-builtins.md) + */ +export interface NewForBuiltinsRule { + /** + * Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`. + * + * @see [new-for-builtins](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/new-for-builtins.md) + */ + 'unicorn/new-for-builtins': NewForBuiltinsRuleConfig; +} diff --git a/src/rules/unicorn/no-abusive-eslint-disable.d.ts b/src/rules/unicorn/no-abusive-eslint-disable.d.ts new file mode 100644 index 00000000..ae546dca --- /dev/null +++ b/src/rules/unicorn/no-abusive-eslint-disable.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce specifying rules to disable in `eslint-disable` comments. + * + * @see [no-abusive-eslint-disable](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-abusive-eslint-disable.md) + */ +export type NoAbusiveEslintDisableRuleConfig = RuleConfig<[]>; + +/** + * Enforce specifying rules to disable in `eslint-disable` comments. + * + * @see [no-abusive-eslint-disable](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-abusive-eslint-disable.md) + */ +export interface NoAbusiveEslintDisableRule { + /** + * Enforce specifying rules to disable in `eslint-disable` comments. + * + * @see [no-abusive-eslint-disable](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-abusive-eslint-disable.md) + */ + 'unicorn/no-abusive-eslint-disable': NoAbusiveEslintDisableRuleConfig; +} diff --git a/src/rules/unicorn/no-array-callback-reference.d.ts b/src/rules/unicorn/no-array-callback-reference.d.ts new file mode 100644 index 00000000..a77a69c4 --- /dev/null +++ b/src/rules/unicorn/no-array-callback-reference.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prevent passing a function reference directly to iterator methods. + * + * @see [no-array-callback-reference](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-callback-reference.md) + */ +export type NoArrayCallbackReferenceRuleConfig = RuleConfig<[]>; + +/** + * Prevent passing a function reference directly to iterator methods. + * + * @see [no-array-callback-reference](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-callback-reference.md) + */ +export interface NoArrayCallbackReferenceRule { + /** + * Prevent passing a function reference directly to iterator methods. + * + * @see [no-array-callback-reference](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-callback-reference.md) + */ + 'unicorn/no-array-callback-reference': NoArrayCallbackReferenceRuleConfig; +} diff --git a/src/rules/unicorn/no-array-for-each.d.ts b/src/rules/unicorn/no-array-for-each.d.ts new file mode 100644 index 00000000..fb1e4fae --- /dev/null +++ b/src/rules/unicorn/no-array-for-each.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `for…of` over `Array#forEach(…)`. + * + * @see [no-array-for-each](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-for-each.md) + */ +export type NoArrayForEachRuleConfig = RuleConfig<[]>; + +/** + * Prefer `for…of` over `Array#forEach(…)`. + * + * @see [no-array-for-each](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-for-each.md) + */ +export interface NoArrayForEachRule { + /** + * Prefer `for…of` over `Array#forEach(…)`. + * + * @see [no-array-for-each](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-for-each.md) + */ + 'unicorn/no-array-for-each': NoArrayForEachRuleConfig; +} diff --git a/src/rules/unicorn/no-array-instanceof.d.ts b/src/rules/unicorn/no-array-instanceof.d.ts new file mode 100644 index 00000000..7a71b835 --- /dev/null +++ b/src/rules/unicorn/no-array-instanceof.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [no-array-instanceof](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#no-array-instanceof) + */ +export type NoArrayInstanceofRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [no-array-instanceof](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#no-array-instanceof) + */ +export interface NoArrayInstanceofRule { + /** + * + * + * @deprecated + * + * @see [no-array-instanceof](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#no-array-instanceof) + */ + 'unicorn/no-array-instanceof': NoArrayInstanceofRuleConfig; +} diff --git a/src/rules/unicorn/no-array-method-this-argument.d.ts b/src/rules/unicorn/no-array-method-this-argument.d.ts new file mode 100644 index 00000000..cd9fa3d3 --- /dev/null +++ b/src/rules/unicorn/no-array-method-this-argument.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow using the `this` argument in array methods. + * + * @see [no-array-method-this-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-method-this-argument.md) + */ +export type NoArrayMethodThisArgumentRuleConfig = RuleConfig<[]>; + +/** + * Disallow using the `this` argument in array methods. + * + * @see [no-array-method-this-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-method-this-argument.md) + */ +export interface NoArrayMethodThisArgumentRule { + /** + * Disallow using the `this` argument in array methods. + * + * @see [no-array-method-this-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-method-this-argument.md) + */ + 'unicorn/no-array-method-this-argument': NoArrayMethodThisArgumentRuleConfig; +} diff --git a/src/rules/unicorn/no-array-push-push.d.ts b/src/rules/unicorn/no-array-push-push.d.ts new file mode 100644 index 00000000..bd6e7c34 --- /dev/null +++ b/src/rules/unicorn/no-array-push-push.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoArrayPushPushOption { + ignore?: any[]; +} + +/** + * Options. + */ +export type NoArrayPushPushOptions = [NoArrayPushPushOption?]; + +/** + * Enforce combining multiple `Array#push()` into one call. + * + * @see [no-array-push-push](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-push-push.md) + */ +export type NoArrayPushPushRuleConfig = RuleConfig; + +/** + * Enforce combining multiple `Array#push()` into one call. + * + * @see [no-array-push-push](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-push-push.md) + */ +export interface NoArrayPushPushRule { + /** + * Enforce combining multiple `Array#push()` into one call. + * + * @see [no-array-push-push](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-push-push.md) + */ + 'unicorn/no-array-push-push': NoArrayPushPushRuleConfig; +} diff --git a/src/rules/unicorn/no-array-reduce.d.ts b/src/rules/unicorn/no-array-reduce.d.ts new file mode 100644 index 00000000..bfc198ee --- /dev/null +++ b/src/rules/unicorn/no-array-reduce.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoArrayReduceOption { + allowSimpleOperations?: boolean; + [k: string]: any; +} + +/** + * Options. + */ +export type NoArrayReduceOptions = [NoArrayReduceOption?]; + +/** + * Disallow `Array#reduce()` and `Array#reduceRight()`. + * + * @see [no-array-reduce](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-reduce.md) + */ +export type NoArrayReduceRuleConfig = RuleConfig; + +/** + * Disallow `Array#reduce()` and `Array#reduceRight()`. + * + * @see [no-array-reduce](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-reduce.md) + */ +export interface NoArrayReduceRule { + /** + * Disallow `Array#reduce()` and `Array#reduceRight()`. + * + * @see [no-array-reduce](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-array-reduce.md) + */ + 'unicorn/no-array-reduce': NoArrayReduceRuleConfig; +} diff --git a/src/rules/unicorn/no-console-spaces.d.ts b/src/rules/unicorn/no-console-spaces.d.ts new file mode 100644 index 00000000..2402bf2d --- /dev/null +++ b/src/rules/unicorn/no-console-spaces.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Do not use leading/trailing space between `console.log` parameters. + * + * @see [no-console-spaces](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-console-spaces.md) + */ +export type NoConsoleSpacesRuleConfig = RuleConfig<[]>; + +/** + * Do not use leading/trailing space between `console.log` parameters. + * + * @see [no-console-spaces](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-console-spaces.md) + */ +export interface NoConsoleSpacesRule { + /** + * Do not use leading/trailing space between `console.log` parameters. + * + * @see [no-console-spaces](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-console-spaces.md) + */ + 'unicorn/no-console-spaces': NoConsoleSpacesRuleConfig; +} diff --git a/src/rules/unicorn/no-document-cookie.d.ts b/src/rules/unicorn/no-document-cookie.d.ts new file mode 100644 index 00000000..a0fb8540 --- /dev/null +++ b/src/rules/unicorn/no-document-cookie.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Do not use `document.cookie` directly. + * + * @see [no-document-cookie](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-document-cookie.md) + */ +export type NoDocumentCookieRuleConfig = RuleConfig<[]>; + +/** + * Do not use `document.cookie` directly. + * + * @see [no-document-cookie](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-document-cookie.md) + */ +export interface NoDocumentCookieRule { + /** + * Do not use `document.cookie` directly. + * + * @see [no-document-cookie](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-document-cookie.md) + */ + 'unicorn/no-document-cookie': NoDocumentCookieRuleConfig; +} diff --git a/src/rules/unicorn/no-fn-reference-in-iterator.d.ts b/src/rules/unicorn/no-fn-reference-in-iterator.d.ts new file mode 100644 index 00000000..69304b58 --- /dev/null +++ b/src/rules/unicorn/no-fn-reference-in-iterator.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [no-fn-reference-in-iterator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#no-fn-reference-in-iterator) + */ +export type NoFnReferenceInIteratorRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [no-fn-reference-in-iterator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#no-fn-reference-in-iterator) + */ +export interface NoFnReferenceInIteratorRule { + /** + * + * + * @deprecated + * + * @see [no-fn-reference-in-iterator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#no-fn-reference-in-iterator) + */ + 'unicorn/no-fn-reference-in-iterator': NoFnReferenceInIteratorRuleConfig; +} diff --git a/src/rules/unicorn/no-for-loop.d.ts b/src/rules/unicorn/no-for-loop.d.ts new file mode 100644 index 00000000..4272a067 --- /dev/null +++ b/src/rules/unicorn/no-for-loop.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Do not use a `for` loop that can be replaced with a `for-of` loop. + * + * @see [no-for-loop](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-for-loop.md) + */ +export type NoForLoopRuleConfig = RuleConfig<[]>; + +/** + * Do not use a `for` loop that can be replaced with a `for-of` loop. + * + * @see [no-for-loop](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-for-loop.md) + */ +export interface NoForLoopRule { + /** + * Do not use a `for` loop that can be replaced with a `for-of` loop. + * + * @see [no-for-loop](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-for-loop.md) + */ + 'unicorn/no-for-loop': NoForLoopRuleConfig; +} diff --git a/src/rules/unicorn/no-hex-escape.d.ts b/src/rules/unicorn/no-hex-escape.d.ts new file mode 100644 index 00000000..950b702e --- /dev/null +++ b/src/rules/unicorn/no-hex-escape.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce the use of Unicode escapes instead of hexadecimal escapes. + * + * @see [no-hex-escape](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-hex-escape.md) + */ +export type NoHexEscapeRuleConfig = RuleConfig<[]>; + +/** + * Enforce the use of Unicode escapes instead of hexadecimal escapes. + * + * @see [no-hex-escape](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-hex-escape.md) + */ +export interface NoHexEscapeRule { + /** + * Enforce the use of Unicode escapes instead of hexadecimal escapes. + * + * @see [no-hex-escape](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-hex-escape.md) + */ + 'unicorn/no-hex-escape': NoHexEscapeRuleConfig; +} diff --git a/src/rules/unicorn/no-instanceof-array.d.ts b/src/rules/unicorn/no-instanceof-array.d.ts new file mode 100644 index 00000000..4bf80bfd --- /dev/null +++ b/src/rules/unicorn/no-instanceof-array.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Require `Array.isArray()` instead of `instanceof Array`. + * + * @see [no-instanceof-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-instanceof-array.md) + */ +export type NoInstanceofArrayRuleConfig = RuleConfig<[]>; + +/** + * Require `Array.isArray()` instead of `instanceof Array`. + * + * @see [no-instanceof-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-instanceof-array.md) + */ +export interface NoInstanceofArrayRule { + /** + * Require `Array.isArray()` instead of `instanceof Array`. + * + * @see [no-instanceof-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-instanceof-array.md) + */ + 'unicorn/no-instanceof-array': NoInstanceofArrayRuleConfig; +} diff --git a/src/rules/unicorn/no-invalid-remove-event-listener.d.ts b/src/rules/unicorn/no-invalid-remove-event-listener.d.ts new file mode 100644 index 00000000..341cd979 --- /dev/null +++ b/src/rules/unicorn/no-invalid-remove-event-listener.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prevent calling `EventTarget#removeEventListener()` with the result of an expression. + * + * @see [no-invalid-remove-event-listener](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-invalid-remove-event-listener.md) + */ +export type NoInvalidRemoveEventListenerRuleConfig = RuleConfig<[]>; + +/** + * Prevent calling `EventTarget#removeEventListener()` with the result of an expression. + * + * @see [no-invalid-remove-event-listener](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-invalid-remove-event-listener.md) + */ +export interface NoInvalidRemoveEventListenerRule { + /** + * Prevent calling `EventTarget#removeEventListener()` with the result of an expression. + * + * @see [no-invalid-remove-event-listener](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-invalid-remove-event-listener.md) + */ + 'unicorn/no-invalid-remove-event-listener': NoInvalidRemoveEventListenerRuleConfig; +} diff --git a/src/rules/unicorn/no-keyword-prefix.d.ts b/src/rules/unicorn/no-keyword-prefix.d.ts new file mode 100644 index 00000000..ccdcd23a --- /dev/null +++ b/src/rules/unicorn/no-keyword-prefix.d.ts @@ -0,0 +1,36 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoKeywordPrefixOption { + disallowedPrefixes?: [] | [string]; + checkProperties?: boolean; + onlyCamelCase?: boolean; +} + +/** + * Options. + */ +export type NoKeywordPrefixOptions = [NoKeywordPrefixOption?]; + +/** + * Disallow identifiers starting with `new` or `class`. + * + * @see [no-keyword-prefix](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-keyword-prefix.md) + */ +export type NoKeywordPrefixRuleConfig = RuleConfig; + +/** + * Disallow identifiers starting with `new` or `class`. + * + * @see [no-keyword-prefix](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-keyword-prefix.md) + */ +export interface NoKeywordPrefixRule { + /** + * Disallow identifiers starting with `new` or `class`. + * + * @see [no-keyword-prefix](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-keyword-prefix.md) + */ + 'unicorn/no-keyword-prefix': NoKeywordPrefixRuleConfig; +} diff --git a/src/rules/unicorn/no-lonely-if.d.ts b/src/rules/unicorn/no-lonely-if.d.ts new file mode 100644 index 00000000..818dede7 --- /dev/null +++ b/src/rules/unicorn/no-lonely-if.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow `if` statements as the only statement in `if` blocks without `else`. + * + * @see [no-lonely-if](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-lonely-if.md) + */ +export type NoLonelyIfRuleConfig = RuleConfig<[]>; + +/** + * Disallow `if` statements as the only statement in `if` blocks without `else`. + * + * @see [no-lonely-if](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-lonely-if.md) + */ +export interface NoLonelyIfRule { + /** + * Disallow `if` statements as the only statement in `if` blocks without `else`. + * + * @see [no-lonely-if](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-lonely-if.md) + */ + 'unicorn/no-lonely-if': NoLonelyIfRuleConfig; +} diff --git a/src/rules/unicorn/no-nested-ternary.d.ts b/src/rules/unicorn/no-nested-ternary.d.ts new file mode 100644 index 00000000..f085076d --- /dev/null +++ b/src/rules/unicorn/no-nested-ternary.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow nested ternary expressions. + * + * @see [no-nested-ternary](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-nested-ternary.md) + */ +export type NoNestedTernaryRuleConfig = RuleConfig<[]>; + +/** + * Disallow nested ternary expressions. + * + * @see [no-nested-ternary](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-nested-ternary.md) + */ +export interface NoNestedTernaryRule { + /** + * Disallow nested ternary expressions. + * + * @see [no-nested-ternary](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-nested-ternary.md) + */ + 'unicorn/no-nested-ternary': NoNestedTernaryRuleConfig; +} diff --git a/src/rules/unicorn/no-new-array.d.ts b/src/rules/unicorn/no-new-array.d.ts new file mode 100644 index 00000000..c7d9cceb --- /dev/null +++ b/src/rules/unicorn/no-new-array.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow `new Array()`. + * + * @see [no-new-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-new-array.md) + */ +export type NoNewArrayRuleConfig = RuleConfig<[]>; + +/** + * Disallow `new Array()`. + * + * @see [no-new-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-new-array.md) + */ +export interface NoNewArrayRule { + /** + * Disallow `new Array()`. + * + * @see [no-new-array](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-new-array.md) + */ + 'unicorn/no-new-array': NoNewArrayRuleConfig; +} diff --git a/src/rules/unicorn/no-new-buffer.d.ts b/src/rules/unicorn/no-new-buffer.d.ts new file mode 100644 index 00000000..b29a695b --- /dev/null +++ b/src/rules/unicorn/no-new-buffer.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`. + * + * @see [no-new-buffer](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-new-buffer.md) + */ +export type NoNewBufferRuleConfig = RuleConfig<[]>; + +/** + * Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`. + * + * @see [no-new-buffer](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-new-buffer.md) + */ +export interface NoNewBufferRule { + /** + * Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`. + * + * @see [no-new-buffer](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-new-buffer.md) + */ + 'unicorn/no-new-buffer': NoNewBufferRuleConfig; +} diff --git a/src/rules/unicorn/no-null.d.ts b/src/rules/unicorn/no-null.d.ts new file mode 100644 index 00000000..339c3473 --- /dev/null +++ b/src/rules/unicorn/no-null.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoNullOption { + checkStrictEquality?: boolean; +} + +/** + * Options. + */ +export type NoNullOptions = [NoNullOption?]; + +/** + * Disallow the use of the `null` literal. + * + * @see [no-null](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-null.md) + */ +export type NoNullRuleConfig = RuleConfig; + +/** + * Disallow the use of the `null` literal. + * + * @see [no-null](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-null.md) + */ +export interface NoNullRule { + /** + * Disallow the use of the `null` literal. + * + * @see [no-null](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-null.md) + */ + 'unicorn/no-null': NoNullRuleConfig; +} diff --git a/src/rules/unicorn/no-object-as-default-parameter.d.ts b/src/rules/unicorn/no-object-as-default-parameter.d.ts new file mode 100644 index 00000000..298fc1c5 --- /dev/null +++ b/src/rules/unicorn/no-object-as-default-parameter.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow the use of objects as default parameters. + * + * @see [no-object-as-default-parameter](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-object-as-default-parameter.md) + */ +export type NoObjectAsDefaultParameterRuleConfig = RuleConfig<[]>; + +/** + * Disallow the use of objects as default parameters. + * + * @see [no-object-as-default-parameter](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-object-as-default-parameter.md) + */ +export interface NoObjectAsDefaultParameterRule { + /** + * Disallow the use of objects as default parameters. + * + * @see [no-object-as-default-parameter](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-object-as-default-parameter.md) + */ + 'unicorn/no-object-as-default-parameter': NoObjectAsDefaultParameterRuleConfig; +} diff --git a/src/rules/unicorn/no-process-exit.d.ts b/src/rules/unicorn/no-process-exit.d.ts new file mode 100644 index 00000000..1ffdc5b5 --- /dev/null +++ b/src/rules/unicorn/no-process-exit.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow `process.exit()`. + * + * @see [no-process-exit](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-process-exit.md) + */ +export type NoProcessExitRuleConfig = RuleConfig<[]>; + +/** + * Disallow `process.exit()`. + * + * @see [no-process-exit](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-process-exit.md) + */ +export interface NoProcessExitRule { + /** + * Disallow `process.exit()`. + * + * @see [no-process-exit](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-process-exit.md) + */ + 'unicorn/no-process-exit': NoProcessExitRuleConfig; +} diff --git a/src/rules/unicorn/no-reduce.d.ts b/src/rules/unicorn/no-reduce.d.ts new file mode 100644 index 00000000..bbc64ad4 --- /dev/null +++ b/src/rules/unicorn/no-reduce.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [no-reduce](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#no-reduce) + */ +export type NoReduceRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [no-reduce](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#no-reduce) + */ +export interface NoReduceRule { + /** + * + * + * @deprecated + * + * @see [no-reduce](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#no-reduce) + */ + 'unicorn/no-reduce': NoReduceRuleConfig; +} diff --git a/src/rules/unicorn/no-static-only-class.d.ts b/src/rules/unicorn/no-static-only-class.d.ts new file mode 100644 index 00000000..99c8f771 --- /dev/null +++ b/src/rules/unicorn/no-static-only-class.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Forbid classes that only have static members. + * + * @see [no-static-only-class](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-static-only-class.md) + */ +export type NoStaticOnlyClassRuleConfig = RuleConfig<[]>; + +/** + * Forbid classes that only have static members. + * + * @see [no-static-only-class](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-static-only-class.md) + */ +export interface NoStaticOnlyClassRule { + /** + * Forbid classes that only have static members. + * + * @see [no-static-only-class](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-static-only-class.md) + */ + 'unicorn/no-static-only-class': NoStaticOnlyClassRuleConfig; +} diff --git a/src/rules/unicorn/no-this-assignment.d.ts b/src/rules/unicorn/no-this-assignment.d.ts new file mode 100644 index 00000000..3ddaff62 --- /dev/null +++ b/src/rules/unicorn/no-this-assignment.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow assigning `this` to a variable. + * + * @see [no-this-assignment](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-this-assignment.md) + */ +export type NoThisAssignmentRuleConfig = RuleConfig<[]>; + +/** + * Disallow assigning `this` to a variable. + * + * @see [no-this-assignment](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-this-assignment.md) + */ +export interface NoThisAssignmentRule { + /** + * Disallow assigning `this` to a variable. + * + * @see [no-this-assignment](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-this-assignment.md) + */ + 'unicorn/no-this-assignment': NoThisAssignmentRuleConfig; +} diff --git a/src/rules/unicorn/no-unreadable-array-destructuring.d.ts b/src/rules/unicorn/no-unreadable-array-destructuring.d.ts new file mode 100644 index 00000000..a8a8c882 --- /dev/null +++ b/src/rules/unicorn/no-unreadable-array-destructuring.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow unreadable array destructuring. + * + * @see [no-unreadable-array-destructuring](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-unreadable-array-destructuring.md) + */ +export type NoUnreadableArrayDestructuringRuleConfig = RuleConfig<[]>; + +/** + * Disallow unreadable array destructuring. + * + * @see [no-unreadable-array-destructuring](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-unreadable-array-destructuring.md) + */ +export interface NoUnreadableArrayDestructuringRule { + /** + * Disallow unreadable array destructuring. + * + * @see [no-unreadable-array-destructuring](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-unreadable-array-destructuring.md) + */ + 'unicorn/no-unreadable-array-destructuring': NoUnreadableArrayDestructuringRuleConfig; +} diff --git a/src/rules/unicorn/no-unsafe-regex.d.ts b/src/rules/unicorn/no-unsafe-regex.d.ts new file mode 100644 index 00000000..0a1660ae --- /dev/null +++ b/src/rules/unicorn/no-unsafe-regex.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow unsafe regular expressions. + * + * @see [no-unsafe-regex](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-unsafe-regex.md) + */ +export type NoUnsafeRegexRuleConfig = RuleConfig<[]>; + +/** + * Disallow unsafe regular expressions. + * + * @see [no-unsafe-regex](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-unsafe-regex.md) + */ +export interface NoUnsafeRegexRule { + /** + * Disallow unsafe regular expressions. + * + * @see [no-unsafe-regex](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-unsafe-regex.md) + */ + 'unicorn/no-unsafe-regex': NoUnsafeRegexRuleConfig; +} diff --git a/src/rules/unicorn/no-unused-properties.d.ts b/src/rules/unicorn/no-unused-properties.d.ts new file mode 100644 index 00000000..fdfb6c63 --- /dev/null +++ b/src/rules/unicorn/no-unused-properties.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow unused object properties. + * + * @see [no-unused-properties](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-unused-properties.md) + */ +export type NoUnusedPropertiesRuleConfig = RuleConfig<[]>; + +/** + * Disallow unused object properties. + * + * @see [no-unused-properties](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-unused-properties.md) + */ +export interface NoUnusedPropertiesRule { + /** + * Disallow unused object properties. + * + * @see [no-unused-properties](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-unused-properties.md) + */ + 'unicorn/no-unused-properties': NoUnusedPropertiesRuleConfig; +} diff --git a/src/rules/unicorn/no-useless-fallback-in-spread.d.ts b/src/rules/unicorn/no-useless-fallback-in-spread.d.ts new file mode 100644 index 00000000..705f8175 --- /dev/null +++ b/src/rules/unicorn/no-useless-fallback-in-spread.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Forbid useless fallback when spreading in object literals. + * + * @see [no-useless-fallback-in-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-fallback-in-spread.md) + */ +export type NoUselessFallbackInSpreadRuleConfig = RuleConfig<[]>; + +/** + * Forbid useless fallback when spreading in object literals. + * + * @see [no-useless-fallback-in-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-fallback-in-spread.md) + */ +export interface NoUselessFallbackInSpreadRule { + /** + * Forbid useless fallback when spreading in object literals. + * + * @see [no-useless-fallback-in-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-fallback-in-spread.md) + */ + 'unicorn/no-useless-fallback-in-spread': NoUselessFallbackInSpreadRuleConfig; +} diff --git a/src/rules/unicorn/no-useless-length-check.d.ts b/src/rules/unicorn/no-useless-length-check.d.ts new file mode 100644 index 00000000..d4c34e71 --- /dev/null +++ b/src/rules/unicorn/no-useless-length-check.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow useless array length check. + * + * @see [no-useless-length-check](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-length-check.md) + */ +export type NoUselessLengthCheckRuleConfig = RuleConfig<[]>; + +/** + * Disallow useless array length check. + * + * @see [no-useless-length-check](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-length-check.md) + */ +export interface NoUselessLengthCheckRule { + /** + * Disallow useless array length check. + * + * @see [no-useless-length-check](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-length-check.md) + */ + 'unicorn/no-useless-length-check': NoUselessLengthCheckRuleConfig; +} diff --git a/src/rules/unicorn/no-useless-spread.d.ts b/src/rules/unicorn/no-useless-spread.d.ts new file mode 100644 index 00000000..3497e73c --- /dev/null +++ b/src/rules/unicorn/no-useless-spread.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow unnecessary spread. + * + * @see [no-useless-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-spread.md) + */ +export type NoUselessSpreadRuleConfig = RuleConfig<[]>; + +/** + * Disallow unnecessary spread. + * + * @see [no-useless-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-spread.md) + */ +export interface NoUselessSpreadRule { + /** + * Disallow unnecessary spread. + * + * @see [no-useless-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-spread.md) + */ + 'unicorn/no-useless-spread': NoUselessSpreadRuleConfig; +} diff --git a/src/rules/unicorn/no-useless-undefined.d.ts b/src/rules/unicorn/no-useless-undefined.d.ts new file mode 100644 index 00000000..6cea65db --- /dev/null +++ b/src/rules/unicorn/no-useless-undefined.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NoUselessUndefinedOption { + checkArguments?: boolean; +} + +/** + * Options. + */ +export type NoUselessUndefinedOptions = [NoUselessUndefinedOption?]; + +/** + * Disallow useless `undefined`. + * + * @see [no-useless-undefined](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-undefined.md) + */ +export type NoUselessUndefinedRuleConfig = RuleConfig; + +/** + * Disallow useless `undefined`. + * + * @see [no-useless-undefined](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-undefined.md) + */ +export interface NoUselessUndefinedRule { + /** + * Disallow useless `undefined`. + * + * @see [no-useless-undefined](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-useless-undefined.md) + */ + 'unicorn/no-useless-undefined': NoUselessUndefinedRuleConfig; +} diff --git a/src/rules/unicorn/no-zero-fractions.d.ts b/src/rules/unicorn/no-zero-fractions.d.ts new file mode 100644 index 00000000..77dc8e48 --- /dev/null +++ b/src/rules/unicorn/no-zero-fractions.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Disallow number literals with zero fractions or dangling dots. + * + * @see [no-zero-fractions](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-zero-fractions.md) + */ +export type NoZeroFractionsRuleConfig = RuleConfig<[]>; + +/** + * Disallow number literals with zero fractions or dangling dots. + * + * @see [no-zero-fractions](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-zero-fractions.md) + */ +export interface NoZeroFractionsRule { + /** + * Disallow number literals with zero fractions or dangling dots. + * + * @see [no-zero-fractions](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/no-zero-fractions.md) + */ + 'unicorn/no-zero-fractions': NoZeroFractionsRuleConfig; +} diff --git a/src/rules/unicorn/number-literal-case.d.ts b/src/rules/unicorn/number-literal-case.d.ts new file mode 100644 index 00000000..fb9f1739 --- /dev/null +++ b/src/rules/unicorn/number-literal-case.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce proper case for numeric literals. + * + * @see [number-literal-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/number-literal-case.md) + */ +export type NumberLiteralCaseRuleConfig = RuleConfig<[]>; + +/** + * Enforce proper case for numeric literals. + * + * @see [number-literal-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/number-literal-case.md) + */ +export interface NumberLiteralCaseRule { + /** + * Enforce proper case for numeric literals. + * + * @see [number-literal-case](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/number-literal-case.md) + */ + 'unicorn/number-literal-case': NumberLiteralCaseRuleConfig; +} diff --git a/src/rules/unicorn/numeric-separators-style.d.ts b/src/rules/unicorn/numeric-separators-style.d.ts new file mode 100644 index 00000000..99b7faeb --- /dev/null +++ b/src/rules/unicorn/numeric-separators-style.d.ts @@ -0,0 +1,54 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface NumericSeparatorsStyleOption { + binary?: { + onlyIfContainsSeparator?: boolean; + minimumDigits?: number; + groupLength?: number; + }; + octal?: { + onlyIfContainsSeparator?: boolean; + minimumDigits?: number; + groupLength?: number; + }; + hexadecimal?: { + onlyIfContainsSeparator?: boolean; + minimumDigits?: number; + groupLength?: number; + }; + number?: { + onlyIfContainsSeparator?: boolean; + minimumDigits?: number; + groupLength?: number; + }; + onlyIfContainsSeparator?: boolean; +} + +/** + * Options. + */ +export type NumericSeparatorsStyleOptions = [NumericSeparatorsStyleOption?]; + +/** + * Enforce the style of numeric separators by correctly grouping digits. + * + * @see [numeric-separators-style](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/numeric-separators-style.md) + */ +export type NumericSeparatorsStyleRuleConfig = RuleConfig; + +/** + * Enforce the style of numeric separators by correctly grouping digits. + * + * @see [numeric-separators-style](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/numeric-separators-style.md) + */ +export interface NumericSeparatorsStyleRule { + /** + * Enforce the style of numeric separators by correctly grouping digits. + * + * @see [numeric-separators-style](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/numeric-separators-style.md) + */ + 'unicorn/numeric-separators-style': NumericSeparatorsStyleRuleConfig; +} diff --git a/src/rules/unicorn/prefer-add-event-listener.d.ts b/src/rules/unicorn/prefer-add-event-listener.d.ts new file mode 100644 index 00000000..72b5c7d4 --- /dev/null +++ b/src/rules/unicorn/prefer-add-event-listener.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferAddEventListenerOption { + excludedPackages?: string[]; +} + +/** + * Options. + */ +export type PreferAddEventListenerOptions = [PreferAddEventListenerOption?]; + +/** + * Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions. + * + * @see [prefer-add-event-listener](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-add-event-listener.md) + */ +export type PreferAddEventListenerRuleConfig = RuleConfig; + +/** + * Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions. + * + * @see [prefer-add-event-listener](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-add-event-listener.md) + */ +export interface PreferAddEventListenerRule { + /** + * Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions. + * + * @see [prefer-add-event-listener](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-add-event-listener.md) + */ + 'unicorn/prefer-add-event-listener': PreferAddEventListenerRuleConfig; +} diff --git a/src/rules/unicorn/prefer-array-find.d.ts b/src/rules/unicorn/prefer-array-find.d.ts new file mode 100644 index 00000000..358caba4 --- /dev/null +++ b/src/rules/unicorn/prefer-array-find.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `.find(…)` over the first element from `.filter(…)`. + * + * @see [prefer-array-find](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-find.md) + */ +export type PreferArrayFindRuleConfig = RuleConfig<[]>; + +/** + * Prefer `.find(…)` over the first element from `.filter(…)`. + * + * @see [prefer-array-find](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-find.md) + */ +export interface PreferArrayFindRule { + /** + * Prefer `.find(…)` over the first element from `.filter(…)`. + * + * @see [prefer-array-find](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-find.md) + */ + 'unicorn/prefer-array-find': PreferArrayFindRuleConfig; +} diff --git a/src/rules/unicorn/prefer-array-flat-map.d.ts b/src/rules/unicorn/prefer-array-flat-map.d.ts new file mode 100644 index 00000000..96458c0a --- /dev/null +++ b/src/rules/unicorn/prefer-array-flat-map.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `.flatMap(…)` over `.map(…).flat()`. + * + * @see [prefer-array-flat-map](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-flat-map.md) + */ +export type PreferArrayFlatMapRuleConfig = RuleConfig<[]>; + +/** + * Prefer `.flatMap(…)` over `.map(…).flat()`. + * + * @see [prefer-array-flat-map](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-flat-map.md) + */ +export interface PreferArrayFlatMapRule { + /** + * Prefer `.flatMap(…)` over `.map(…).flat()`. + * + * @see [prefer-array-flat-map](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-flat-map.md) + */ + 'unicorn/prefer-array-flat-map': PreferArrayFlatMapRuleConfig; +} diff --git a/src/rules/unicorn/prefer-array-flat.d.ts b/src/rules/unicorn/prefer-array-flat.d.ts new file mode 100644 index 00000000..1e2486a0 --- /dev/null +++ b/src/rules/unicorn/prefer-array-flat.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferArrayFlatOption { + functions?: any[]; +} + +/** + * Options. + */ +export type PreferArrayFlatOptions = [PreferArrayFlatOption?]; + +/** + * Prefer `Array#flat()` over legacy techniques to flatten arrays. + * + * @see [prefer-array-flat](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-flat.md) + */ +export type PreferArrayFlatRuleConfig = RuleConfig; + +/** + * Prefer `Array#flat()` over legacy techniques to flatten arrays. + * + * @see [prefer-array-flat](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-flat.md) + */ +export interface PreferArrayFlatRule { + /** + * Prefer `Array#flat()` over legacy techniques to flatten arrays. + * + * @see [prefer-array-flat](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-flat.md) + */ + 'unicorn/prefer-array-flat': PreferArrayFlatRuleConfig; +} diff --git a/src/rules/unicorn/prefer-array-index-of.d.ts b/src/rules/unicorn/prefer-array-index-of.d.ts new file mode 100644 index 00000000..67d9101e --- /dev/null +++ b/src/rules/unicorn/prefer-array-index-of.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `Array#indexOf()` over `Array#findIndex()` when looking for the index of an item. + * + * @see [prefer-array-index-of](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-index-of.md) + */ +export type PreferArrayIndexOfRuleConfig = RuleConfig<[]>; + +/** + * Prefer `Array#indexOf()` over `Array#findIndex()` when looking for the index of an item. + * + * @see [prefer-array-index-of](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-index-of.md) + */ +export interface PreferArrayIndexOfRule { + /** + * Prefer `Array#indexOf()` over `Array#findIndex()` when looking for the index of an item. + * + * @see [prefer-array-index-of](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-index-of.md) + */ + 'unicorn/prefer-array-index-of': PreferArrayIndexOfRuleConfig; +} diff --git a/src/rules/unicorn/prefer-array-some.d.ts b/src/rules/unicorn/prefer-array-some.d.ts new file mode 100644 index 00000000..159593ec --- /dev/null +++ b/src/rules/unicorn/prefer-array-some.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `.some(…)` over `.filter(…).length` check and `.find(…)`. + * + * @see [prefer-array-some](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-some.md) + */ +export type PreferArraySomeRuleConfig = RuleConfig<[]>; + +/** + * Prefer `.some(…)` over `.filter(…).length` check and `.find(…)`. + * + * @see [prefer-array-some](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-some.md) + */ +export interface PreferArraySomeRule { + /** + * Prefer `.some(…)` over `.filter(…).length` check and `.find(…)`. + * + * @see [prefer-array-some](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-array-some.md) + */ + 'unicorn/prefer-array-some': PreferArraySomeRuleConfig; +} diff --git a/src/rules/unicorn/prefer-at.d.ts b/src/rules/unicorn/prefer-at.d.ts new file mode 100644 index 00000000..ce526399 --- /dev/null +++ b/src/rules/unicorn/prefer-at.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferAtOption { + getLastElementFunctions?: any[]; + checkAllIndexAccess?: boolean; +} + +/** + * Options. + */ +export type PreferAtOptions = [PreferAtOption?]; + +/** + * Prefer `.at()` method for index access and `String#charAt()`. + * + * @see [prefer-at](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-at.md) + */ +export type PreferAtRuleConfig = RuleConfig; + +/** + * Prefer `.at()` method for index access and `String#charAt()`. + * + * @see [prefer-at](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-at.md) + */ +export interface PreferAtRule { + /** + * Prefer `.at()` method for index access and `String#charAt()`. + * + * @see [prefer-at](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-at.md) + */ + 'unicorn/prefer-at': PreferAtRuleConfig; +} diff --git a/src/rules/unicorn/prefer-dataset.d.ts b/src/rules/unicorn/prefer-dataset.d.ts new file mode 100644 index 00000000..d0e521fe --- /dev/null +++ b/src/rules/unicorn/prefer-dataset.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-dataset](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-dataset) + */ +export type PreferDatasetRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-dataset](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-dataset) + */ +export interface PreferDatasetRule { + /** + * + * + * @deprecated + * + * @see [prefer-dataset](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-dataset) + */ + 'unicorn/prefer-dataset': PreferDatasetRuleConfig; +} diff --git a/src/rules/unicorn/prefer-date-now.d.ts b/src/rules/unicorn/prefer-date-now.d.ts new file mode 100644 index 00000000..fd5eead9 --- /dev/null +++ b/src/rules/unicorn/prefer-date-now.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch. + * + * @see [prefer-date-now](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-date-now.md) + */ +export type PreferDateNowRuleConfig = RuleConfig<[]>; + +/** + * Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch. + * + * @see [prefer-date-now](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-date-now.md) + */ +export interface PreferDateNowRule { + /** + * Prefer `Date.now()` to get the number of milliseconds since the Unix Epoch. + * + * @see [prefer-date-now](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-date-now.md) + */ + 'unicorn/prefer-date-now': PreferDateNowRuleConfig; +} diff --git a/src/rules/unicorn/prefer-default-parameters.d.ts b/src/rules/unicorn/prefer-default-parameters.d.ts new file mode 100644 index 00000000..4687d7fb --- /dev/null +++ b/src/rules/unicorn/prefer-default-parameters.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer default parameters over reassignment. + * + * @see [prefer-default-parameters](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-default-parameters.md) + */ +export type PreferDefaultParametersRuleConfig = RuleConfig<[]>; + +/** + * Prefer default parameters over reassignment. + * + * @see [prefer-default-parameters](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-default-parameters.md) + */ +export interface PreferDefaultParametersRule { + /** + * Prefer default parameters over reassignment. + * + * @see [prefer-default-parameters](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-default-parameters.md) + */ + 'unicorn/prefer-default-parameters': PreferDefaultParametersRuleConfig; +} diff --git a/src/rules/unicorn/prefer-dom-node-append.d.ts b/src/rules/unicorn/prefer-dom-node-append.d.ts new file mode 100644 index 00000000..da49cce9 --- /dev/null +++ b/src/rules/unicorn/prefer-dom-node-append.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `Node#append()` over `Node#appendChild()`. + * + * @see [prefer-dom-node-append](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-append.md) + */ +export type PreferDomNodeAppendRuleConfig = RuleConfig<[]>; + +/** + * Prefer `Node#append()` over `Node#appendChild()`. + * + * @see [prefer-dom-node-append](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-append.md) + */ +export interface PreferDomNodeAppendRule { + /** + * Prefer `Node#append()` over `Node#appendChild()`. + * + * @see [prefer-dom-node-append](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-append.md) + */ + 'unicorn/prefer-dom-node-append': PreferDomNodeAppendRuleConfig; +} diff --git a/src/rules/unicorn/prefer-dom-node-dataset.d.ts b/src/rules/unicorn/prefer-dom-node-dataset.d.ts new file mode 100644 index 00000000..66e11f95 --- /dev/null +++ b/src/rules/unicorn/prefer-dom-node-dataset.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer using `.dataset` on DOM elements over `.setAttribute(…)`. + * + * @see [prefer-dom-node-dataset](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-dataset.md) + */ +export type PreferDomNodeDatasetRuleConfig = RuleConfig<[]>; + +/** + * Prefer using `.dataset` on DOM elements over `.setAttribute(…)`. + * + * @see [prefer-dom-node-dataset](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-dataset.md) + */ +export interface PreferDomNodeDatasetRule { + /** + * Prefer using `.dataset` on DOM elements over `.setAttribute(…)`. + * + * @see [prefer-dom-node-dataset](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-dataset.md) + */ + 'unicorn/prefer-dom-node-dataset': PreferDomNodeDatasetRuleConfig; +} diff --git a/src/rules/unicorn/prefer-dom-node-remove.d.ts b/src/rules/unicorn/prefer-dom-node-remove.d.ts new file mode 100644 index 00000000..537b1b16 --- /dev/null +++ b/src/rules/unicorn/prefer-dom-node-remove.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`. + * + * @see [prefer-dom-node-remove](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-remove.md) + */ +export type PreferDomNodeRemoveRuleConfig = RuleConfig<[]>; + +/** + * Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`. + * + * @see [prefer-dom-node-remove](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-remove.md) + */ +export interface PreferDomNodeRemoveRule { + /** + * Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`. + * + * @see [prefer-dom-node-remove](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-remove.md) + */ + 'unicorn/prefer-dom-node-remove': PreferDomNodeRemoveRuleConfig; +} diff --git a/src/rules/unicorn/prefer-dom-node-text-content.d.ts b/src/rules/unicorn/prefer-dom-node-text-content.d.ts new file mode 100644 index 00000000..2f6de206 --- /dev/null +++ b/src/rules/unicorn/prefer-dom-node-text-content.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `.textContent` over `.innerText`. + * + * @see [prefer-dom-node-text-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-text-content.md) + */ +export type PreferDomNodeTextContentRuleConfig = RuleConfig<[]>; + +/** + * Prefer `.textContent` over `.innerText`. + * + * @see [prefer-dom-node-text-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-text-content.md) + */ +export interface PreferDomNodeTextContentRule { + /** + * Prefer `.textContent` over `.innerText`. + * + * @see [prefer-dom-node-text-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-dom-node-text-content.md) + */ + 'unicorn/prefer-dom-node-text-content': PreferDomNodeTextContentRuleConfig; +} diff --git a/src/rules/unicorn/prefer-event-key.d.ts b/src/rules/unicorn/prefer-event-key.d.ts new file mode 100644 index 00000000..1db19531 --- /dev/null +++ b/src/rules/unicorn/prefer-event-key.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-event-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-event-key) + */ +export type PreferEventKeyRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-event-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-event-key) + */ +export interface PreferEventKeyRule { + /** + * + * + * @deprecated + * + * @see [prefer-event-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-event-key) + */ + 'unicorn/prefer-event-key': PreferEventKeyRuleConfig; +} diff --git a/src/rules/unicorn/prefer-exponentiation-operator.d.ts b/src/rules/unicorn/prefer-exponentiation-operator.d.ts new file mode 100644 index 00000000..6c59e944 --- /dev/null +++ b/src/rules/unicorn/prefer-exponentiation-operator.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-exponentiation-operator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-exponentiation-operator) + */ +export type PreferExponentiationOperatorRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-exponentiation-operator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-exponentiation-operator) + */ +export interface PreferExponentiationOperatorRule { + /** + * + * + * @deprecated + * + * @see [prefer-exponentiation-operator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-exponentiation-operator) + */ + 'unicorn/prefer-exponentiation-operator': PreferExponentiationOperatorRuleConfig; +} diff --git a/src/rules/unicorn/prefer-flat-map.d.ts b/src/rules/unicorn/prefer-flat-map.d.ts new file mode 100644 index 00000000..2ccc3962 --- /dev/null +++ b/src/rules/unicorn/prefer-flat-map.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-flat-map](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-flat-map) + */ +export type PreferFlatMapRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-flat-map](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-flat-map) + */ +export interface PreferFlatMapRule { + /** + * + * + * @deprecated + * + * @see [prefer-flat-map](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-flat-map) + */ + 'unicorn/prefer-flat-map': PreferFlatMapRuleConfig; +} diff --git a/src/rules/unicorn/prefer-includes.d.ts b/src/rules/unicorn/prefer-includes.d.ts new file mode 100644 index 00000000..b5521ba6 --- /dev/null +++ b/src/rules/unicorn/prefer-includes.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `.includes()` over `.indexOf()` and `Array#some()` when checking for existence or non-existence. + * + * @see [prefer-includes](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-includes.md) + */ +export type PreferIncludesRuleConfig = RuleConfig<[]>; + +/** + * Prefer `.includes()` over `.indexOf()` and `Array#some()` when checking for existence or non-existence. + * + * @see [prefer-includes](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-includes.md) + */ +export interface PreferIncludesRule { + /** + * Prefer `.includes()` over `.indexOf()` and `Array#some()` when checking for existence or non-existence. + * + * @see [prefer-includes](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-includes.md) + */ + 'unicorn/prefer-includes': PreferIncludesRuleConfig; +} diff --git a/src/rules/unicorn/prefer-keyboard-event-key.d.ts b/src/rules/unicorn/prefer-keyboard-event-key.d.ts new file mode 100644 index 00000000..23e0da6c --- /dev/null +++ b/src/rules/unicorn/prefer-keyboard-event-key.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`. + * + * @see [prefer-keyboard-event-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-keyboard-event-key.md) + */ +export type PreferKeyboardEventKeyRuleConfig = RuleConfig<[]>; + +/** + * Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`. + * + * @see [prefer-keyboard-event-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-keyboard-event-key.md) + */ +export interface PreferKeyboardEventKeyRule { + /** + * Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`. + * + * @see [prefer-keyboard-event-key](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-keyboard-event-key.md) + */ + 'unicorn/prefer-keyboard-event-key': PreferKeyboardEventKeyRuleConfig; +} diff --git a/src/rules/unicorn/prefer-math-trunc.d.ts b/src/rules/unicorn/prefer-math-trunc.d.ts new file mode 100644 index 00000000..b043babb --- /dev/null +++ b/src/rules/unicorn/prefer-math-trunc.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce the use of `Math.trunc` instead of bitwise operators. + * + * @see [prefer-math-trunc](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-math-trunc.md) + */ +export type PreferMathTruncRuleConfig = RuleConfig<[]>; + +/** + * Enforce the use of `Math.trunc` instead of bitwise operators. + * + * @see [prefer-math-trunc](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-math-trunc.md) + */ +export interface PreferMathTruncRule { + /** + * Enforce the use of `Math.trunc` instead of bitwise operators. + * + * @see [prefer-math-trunc](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-math-trunc.md) + */ + 'unicorn/prefer-math-trunc': PreferMathTruncRuleConfig; +} diff --git a/src/rules/unicorn/prefer-modern-dom-apis.d.ts b/src/rules/unicorn/prefer-modern-dom-apis.d.ts new file mode 100644 index 00000000..576df522 --- /dev/null +++ b/src/rules/unicorn/prefer-modern-dom-apis.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `.before()` over `.insertBefore()`, `.replaceWith()` over `.replaceChild()`, prefer one of `.before()`, `.after()`, `.append()` or `.prepend()` over `insertAdjacentText()` and `insertAdjacentElement()`. + * + * @see [prefer-modern-dom-apis](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-modern-dom-apis.md) + */ +export type PreferModernDomApisRuleConfig = RuleConfig<[]>; + +/** + * Prefer `.before()` over `.insertBefore()`, `.replaceWith()` over `.replaceChild()`, prefer one of `.before()`, `.after()`, `.append()` or `.prepend()` over `insertAdjacentText()` and `insertAdjacentElement()`. + * + * @see [prefer-modern-dom-apis](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-modern-dom-apis.md) + */ +export interface PreferModernDomApisRule { + /** + * Prefer `.before()` over `.insertBefore()`, `.replaceWith()` over `.replaceChild()`, prefer one of `.before()`, `.after()`, `.append()` or `.prepend()` over `insertAdjacentText()` and `insertAdjacentElement()`. + * + * @see [prefer-modern-dom-apis](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-modern-dom-apis.md) + */ + 'unicorn/prefer-modern-dom-apis': PreferModernDomApisRuleConfig; +} diff --git a/src/rules/unicorn/prefer-module.d.ts b/src/rules/unicorn/prefer-module.d.ts new file mode 100644 index 00000000..29dd7fb5 --- /dev/null +++ b/src/rules/unicorn/prefer-module.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer JavaScript modules (ESM) over CommonJS. + * + * @see [prefer-module](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-module.md) + */ +export type PreferModuleRuleConfig = RuleConfig<[]>; + +/** + * Prefer JavaScript modules (ESM) over CommonJS. + * + * @see [prefer-module](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-module.md) + */ +export interface PreferModuleRule { + /** + * Prefer JavaScript modules (ESM) over CommonJS. + * + * @see [prefer-module](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-module.md) + */ + 'unicorn/prefer-module': PreferModuleRuleConfig; +} diff --git a/src/rules/unicorn/prefer-negative-index.d.ts b/src/rules/unicorn/prefer-negative-index.d.ts new file mode 100644 index 00000000..f1c7d281 --- /dev/null +++ b/src/rules/unicorn/prefer-negative-index.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer negative index over `.length - index` for `{String,Array,TypedArray}#slice()`, `Array#splice()` and `Array#at()`. + * + * @see [prefer-negative-index](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-negative-index.md) + */ +export type PreferNegativeIndexRuleConfig = RuleConfig<[]>; + +/** + * Prefer negative index over `.length - index` for `{String,Array,TypedArray}#slice()`, `Array#splice()` and `Array#at()`. + * + * @see [prefer-negative-index](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-negative-index.md) + */ +export interface PreferNegativeIndexRule { + /** + * Prefer negative index over `.length - index` for `{String,Array,TypedArray}#slice()`, `Array#splice()` and `Array#at()`. + * + * @see [prefer-negative-index](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-negative-index.md) + */ + 'unicorn/prefer-negative-index': PreferNegativeIndexRuleConfig; +} diff --git a/src/rules/unicorn/prefer-node-append.d.ts b/src/rules/unicorn/prefer-node-append.d.ts new file mode 100644 index 00000000..0a12499e --- /dev/null +++ b/src/rules/unicorn/prefer-node-append.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-node-append](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-node-append) + */ +export type PreferNodeAppendRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-node-append](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-node-append) + */ +export interface PreferNodeAppendRule { + /** + * + * + * @deprecated + * + * @see [prefer-node-append](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-node-append) + */ + 'unicorn/prefer-node-append': PreferNodeAppendRuleConfig; +} diff --git a/src/rules/unicorn/prefer-node-protocol.d.ts b/src/rules/unicorn/prefer-node-protocol.d.ts new file mode 100644 index 00000000..9272bc35 --- /dev/null +++ b/src/rules/unicorn/prefer-node-protocol.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferNodeProtocolOption { + checkRequire?: boolean; +} + +/** + * Options. + */ +export type PreferNodeProtocolOptions = [PreferNodeProtocolOption?]; + +/** + * Prefer using the `node:` protocol when importing Node.js builtin modules. + * + * @see [prefer-node-protocol](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-node-protocol.md) + */ +export type PreferNodeProtocolRuleConfig = RuleConfig; + +/** + * Prefer using the `node:` protocol when importing Node.js builtin modules. + * + * @see [prefer-node-protocol](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-node-protocol.md) + */ +export interface PreferNodeProtocolRule { + /** + * Prefer using the `node:` protocol when importing Node.js builtin modules. + * + * @see [prefer-node-protocol](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-node-protocol.md) + */ + 'unicorn/prefer-node-protocol': PreferNodeProtocolRuleConfig; +} diff --git a/src/rules/unicorn/prefer-node-remove.d.ts b/src/rules/unicorn/prefer-node-remove.d.ts new file mode 100644 index 00000000..a4176b8b --- /dev/null +++ b/src/rules/unicorn/prefer-node-remove.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-node-remove](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-node-remove) + */ +export type PreferNodeRemoveRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-node-remove](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-node-remove) + */ +export interface PreferNodeRemoveRule { + /** + * + * + * @deprecated + * + * @see [prefer-node-remove](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-node-remove) + */ + 'unicorn/prefer-node-remove': PreferNodeRemoveRuleConfig; +} diff --git a/src/rules/unicorn/prefer-number-properties.d.ts b/src/rules/unicorn/prefer-number-properties.d.ts new file mode 100644 index 00000000..76002f3c --- /dev/null +++ b/src/rules/unicorn/prefer-number-properties.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferNumberPropertiesOption { + checkInfinity?: boolean; +} + +/** + * Options. + */ +export type PreferNumberPropertiesOptions = [PreferNumberPropertiesOption?]; + +/** + * Prefer `Number` static properties over global ones. + * + * @see [prefer-number-properties](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-number-properties.md) + */ +export type PreferNumberPropertiesRuleConfig = RuleConfig; + +/** + * Prefer `Number` static properties over global ones. + * + * @see [prefer-number-properties](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-number-properties.md) + */ +export interface PreferNumberPropertiesRule { + /** + * Prefer `Number` static properties over global ones. + * + * @see [prefer-number-properties](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-number-properties.md) + */ + 'unicorn/prefer-number-properties': PreferNumberPropertiesRuleConfig; +} diff --git a/src/rules/unicorn/prefer-object-from-entries.d.ts b/src/rules/unicorn/prefer-object-from-entries.d.ts new file mode 100644 index 00000000..f1b30248 --- /dev/null +++ b/src/rules/unicorn/prefer-object-from-entries.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferObjectFromEntriesOption { + functions?: any[]; +} + +/** + * Options. + */ +export type PreferObjectFromEntriesOptions = [PreferObjectFromEntriesOption?]; + +/** + * Prefer using `Object.fromEntries(…)` to transform a list of key-value pairs into an object. + * + * @see [prefer-object-from-entries](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-object-from-entries.md) + */ +export type PreferObjectFromEntriesRuleConfig = RuleConfig; + +/** + * Prefer using `Object.fromEntries(…)` to transform a list of key-value pairs into an object. + * + * @see [prefer-object-from-entries](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-object-from-entries.md) + */ +export interface PreferObjectFromEntriesRule { + /** + * Prefer using `Object.fromEntries(…)` to transform a list of key-value pairs into an object. + * + * @see [prefer-object-from-entries](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-object-from-entries.md) + */ + 'unicorn/prefer-object-from-entries': PreferObjectFromEntriesRuleConfig; +} diff --git a/src/rules/unicorn/prefer-object-has-own.d.ts b/src/rules/unicorn/prefer-object-has-own.d.ts new file mode 100644 index 00000000..fe819964 --- /dev/null +++ b/src/rules/unicorn/prefer-object-has-own.d.ts @@ -0,0 +1,34 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferObjectHasOwnOption { + functions?: any[]; +} + +/** + * Options. + */ +export type PreferObjectHasOwnOptions = [PreferObjectHasOwnOption?]; + +/** + * Prefer `Object.hasOwn(…)` over `Object.prototype.hasOwnProperty.call(…)`. + * + * @see [prefer-object-has-own](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-object-has-own.md) + */ +export type PreferObjectHasOwnRuleConfig = RuleConfig; + +/** + * Prefer `Object.hasOwn(…)` over `Object.prototype.hasOwnProperty.call(…)`. + * + * @see [prefer-object-has-own](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-object-has-own.md) + */ +export interface PreferObjectHasOwnRule { + /** + * Prefer `Object.hasOwn(…)` over `Object.prototype.hasOwnProperty.call(…)`. + * + * @see [prefer-object-has-own](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-object-has-own.md) + */ + 'unicorn/prefer-object-has-own': PreferObjectHasOwnRuleConfig; +} diff --git a/src/rules/unicorn/prefer-optional-catch-binding.d.ts b/src/rules/unicorn/prefer-optional-catch-binding.d.ts new file mode 100644 index 00000000..c57546fe --- /dev/null +++ b/src/rules/unicorn/prefer-optional-catch-binding.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer omitting the `catch` binding parameter. + * + * @see [prefer-optional-catch-binding](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-optional-catch-binding.md) + */ +export type PreferOptionalCatchBindingRuleConfig = RuleConfig<[]>; + +/** + * Prefer omitting the `catch` binding parameter. + * + * @see [prefer-optional-catch-binding](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-optional-catch-binding.md) + */ +export interface PreferOptionalCatchBindingRule { + /** + * Prefer omitting the `catch` binding parameter. + * + * @see [prefer-optional-catch-binding](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-optional-catch-binding.md) + */ + 'unicorn/prefer-optional-catch-binding': PreferOptionalCatchBindingRuleConfig; +} diff --git a/src/rules/unicorn/prefer-prototype-methods.d.ts b/src/rules/unicorn/prefer-prototype-methods.d.ts new file mode 100644 index 00000000..10309ba7 --- /dev/null +++ b/src/rules/unicorn/prefer-prototype-methods.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer borrowing methods from the prototype instead of the instance. + * + * @see [prefer-prototype-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-prototype-methods.md) + */ +export type PreferPrototypeMethodsRuleConfig = RuleConfig<[]>; + +/** + * Prefer borrowing methods from the prototype instead of the instance. + * + * @see [prefer-prototype-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-prototype-methods.md) + */ +export interface PreferPrototypeMethodsRule { + /** + * Prefer borrowing methods from the prototype instead of the instance. + * + * @see [prefer-prototype-methods](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-prototype-methods.md) + */ + 'unicorn/prefer-prototype-methods': PreferPrototypeMethodsRuleConfig; +} diff --git a/src/rules/unicorn/prefer-query-selector.d.ts b/src/rules/unicorn/prefer-query-selector.d.ts new file mode 100644 index 00000000..bda5ef6d --- /dev/null +++ b/src/rules/unicorn/prefer-query-selector.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `.querySelector()` over `.getElementById()`, `.querySelectorAll()` over `.getElementsByClassName()` and `.getElementsByTagName()`. + * + * @see [prefer-query-selector](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-query-selector.md) + */ +export type PreferQuerySelectorRuleConfig = RuleConfig<[]>; + +/** + * Prefer `.querySelector()` over `.getElementById()`, `.querySelectorAll()` over `.getElementsByClassName()` and `.getElementsByTagName()`. + * + * @see [prefer-query-selector](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-query-selector.md) + */ +export interface PreferQuerySelectorRule { + /** + * Prefer `.querySelector()` over `.getElementById()`, `.querySelectorAll()` over `.getElementsByClassName()` and `.getElementsByTagName()`. + * + * @see [prefer-query-selector](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-query-selector.md) + */ + 'unicorn/prefer-query-selector': PreferQuerySelectorRuleConfig; +} diff --git a/src/rules/unicorn/prefer-reflect-apply.d.ts b/src/rules/unicorn/prefer-reflect-apply.d.ts new file mode 100644 index 00000000..5fef7fe6 --- /dev/null +++ b/src/rules/unicorn/prefer-reflect-apply.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `Reflect.apply()` over `Function#apply()`. + * + * @see [prefer-reflect-apply](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-reflect-apply.md) + */ +export type PreferReflectApplyRuleConfig = RuleConfig<[]>; + +/** + * Prefer `Reflect.apply()` over `Function#apply()`. + * + * @see [prefer-reflect-apply](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-reflect-apply.md) + */ +export interface PreferReflectApplyRule { + /** + * Prefer `Reflect.apply()` over `Function#apply()`. + * + * @see [prefer-reflect-apply](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-reflect-apply.md) + */ + 'unicorn/prefer-reflect-apply': PreferReflectApplyRuleConfig; +} diff --git a/src/rules/unicorn/prefer-regexp-test.d.ts b/src/rules/unicorn/prefer-regexp-test.d.ts new file mode 100644 index 00000000..60aee8a7 --- /dev/null +++ b/src/rules/unicorn/prefer-regexp-test.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`. + * + * @see [prefer-regexp-test](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-regexp-test.md) + */ +export type PreferRegexpTestRuleConfig = RuleConfig<[]>; + +/** + * Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`. + * + * @see [prefer-regexp-test](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-regexp-test.md) + */ +export interface PreferRegexpTestRule { + /** + * Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()`. + * + * @see [prefer-regexp-test](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-regexp-test.md) + */ + 'unicorn/prefer-regexp-test': PreferRegexpTestRuleConfig; +} diff --git a/src/rules/unicorn/prefer-replace-all.d.ts b/src/rules/unicorn/prefer-replace-all.d.ts new file mode 100644 index 00000000..605c7b9f --- /dev/null +++ b/src/rules/unicorn/prefer-replace-all.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-replace-all](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-replace-all) + */ +export type PreferReplaceAllRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-replace-all](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-replace-all) + */ +export interface PreferReplaceAllRule { + /** + * + * + * @deprecated + * + * @see [prefer-replace-all](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-replace-all) + */ + 'unicorn/prefer-replace-all': PreferReplaceAllRuleConfig; +} diff --git a/src/rules/unicorn/prefer-set-has.d.ts b/src/rules/unicorn/prefer-set-has.d.ts new file mode 100644 index 00000000..b2a0eb28 --- /dev/null +++ b/src/rules/unicorn/prefer-set-has.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence. + * + * @see [prefer-set-has](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-set-has.md) + */ +export type PreferSetHasRuleConfig = RuleConfig<[]>; + +/** + * Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence. + * + * @see [prefer-set-has](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-set-has.md) + */ +export interface PreferSetHasRule { + /** + * Prefer `Set#has()` over `Array#includes()` when checking for existence or non-existence. + * + * @see [prefer-set-has](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-set-has.md) + */ + 'unicorn/prefer-set-has': PreferSetHasRuleConfig; +} diff --git a/src/rules/unicorn/prefer-spread.d.ts b/src/rules/unicorn/prefer-spread.d.ts new file mode 100644 index 00000000..2042eeb8 --- /dev/null +++ b/src/rules/unicorn/prefer-spread.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#slice()` and `String#split('')`. + * + * @see [prefer-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-spread.md) + */ +export type PreferSpreadRuleConfig = RuleConfig<[]>; + +/** + * Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#slice()` and `String#split('')`. + * + * @see [prefer-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-spread.md) + */ +export interface PreferSpreadRule { + /** + * Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#slice()` and `String#split('')`. + * + * @see [prefer-spread](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-spread.md) + */ + 'unicorn/prefer-spread': PreferSpreadRuleConfig; +} diff --git a/src/rules/unicorn/prefer-starts-ends-with.d.ts b/src/rules/unicorn/prefer-starts-ends-with.d.ts new file mode 100644 index 00000000..f15f1c39 --- /dev/null +++ b/src/rules/unicorn/prefer-starts-ends-with.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-starts-ends-with](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-starts-ends-with) + */ +export type PreferStartsEndsWithRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-starts-ends-with](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-starts-ends-with) + */ +export interface PreferStartsEndsWithRule { + /** + * + * + * @deprecated + * + * @see [prefer-starts-ends-with](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-starts-ends-with) + */ + 'unicorn/prefer-starts-ends-with': PreferStartsEndsWithRuleConfig; +} diff --git a/src/rules/unicorn/prefer-string-replace-all.d.ts b/src/rules/unicorn/prefer-string-replace-all.d.ts new file mode 100644 index 00000000..29d669ac --- /dev/null +++ b/src/rules/unicorn/prefer-string-replace-all.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `String#replaceAll()` over regex searches with the global flag. + * + * @see [prefer-string-replace-all](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-replace-all.md) + */ +export type PreferStringReplaceAllRuleConfig = RuleConfig<[]>; + +/** + * Prefer `String#replaceAll()` over regex searches with the global flag. + * + * @see [prefer-string-replace-all](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-replace-all.md) + */ +export interface PreferStringReplaceAllRule { + /** + * Prefer `String#replaceAll()` over regex searches with the global flag. + * + * @see [prefer-string-replace-all](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-replace-all.md) + */ + 'unicorn/prefer-string-replace-all': PreferStringReplaceAllRuleConfig; +} diff --git a/src/rules/unicorn/prefer-string-slice.d.ts b/src/rules/unicorn/prefer-string-slice.d.ts new file mode 100644 index 00000000..3a49ee50 --- /dev/null +++ b/src/rules/unicorn/prefer-string-slice.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `String#slice()` over `String#substr()` and `String#substring()`. + * + * @see [prefer-string-slice](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-slice.md) + */ +export type PreferStringSliceRuleConfig = RuleConfig<[]>; + +/** + * Prefer `String#slice()` over `String#substr()` and `String#substring()`. + * + * @see [prefer-string-slice](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-slice.md) + */ +export interface PreferStringSliceRule { + /** + * Prefer `String#slice()` over `String#substr()` and `String#substring()`. + * + * @see [prefer-string-slice](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-slice.md) + */ + 'unicorn/prefer-string-slice': PreferStringSliceRuleConfig; +} diff --git a/src/rules/unicorn/prefer-string-starts-ends-with.d.ts b/src/rules/unicorn/prefer-string-starts-ends-with.d.ts new file mode 100644 index 00000000..3263571f --- /dev/null +++ b/src/rules/unicorn/prefer-string-starts-ends-with.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `String#startsWith()` & `String#endsWith()` over `RegExp#test()`. + * + * @see [prefer-string-starts-ends-with](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-starts-ends-with.md) + */ +export type PreferStringStartsEndsWithRuleConfig = RuleConfig<[]>; + +/** + * Prefer `String#startsWith()` & `String#endsWith()` over `RegExp#test()`. + * + * @see [prefer-string-starts-ends-with](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-starts-ends-with.md) + */ +export interface PreferStringStartsEndsWithRule { + /** + * Prefer `String#startsWith()` & `String#endsWith()` over `RegExp#test()`. + * + * @see [prefer-string-starts-ends-with](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-starts-ends-with.md) + */ + 'unicorn/prefer-string-starts-ends-with': PreferStringStartsEndsWithRuleConfig; +} diff --git a/src/rules/unicorn/prefer-string-trim-start-end.d.ts b/src/rules/unicorn/prefer-string-trim-start-end.d.ts new file mode 100644 index 00000000..032b6edd --- /dev/null +++ b/src/rules/unicorn/prefer-string-trim-start-end.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`. + * + * @see [prefer-string-trim-start-end](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-trim-start-end.md) + */ +export type PreferStringTrimStartEndRuleConfig = RuleConfig<[]>; + +/** + * Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`. + * + * @see [prefer-string-trim-start-end](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-trim-start-end.md) + */ +export interface PreferStringTrimStartEndRule { + /** + * Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`. + * + * @see [prefer-string-trim-start-end](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-string-trim-start-end.md) + */ + 'unicorn/prefer-string-trim-start-end': PreferStringTrimStartEndRuleConfig; +} diff --git a/src/rules/unicorn/prefer-switch.d.ts b/src/rules/unicorn/prefer-switch.d.ts new file mode 100644 index 00000000..43091c5b --- /dev/null +++ b/src/rules/unicorn/prefer-switch.d.ts @@ -0,0 +1,35 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface PreferSwitchOption { + minimumCases?: number; + emptyDefaultCase?: 'no-default-comment' | 'do-nothing-comment' | 'no-default-case'; +} + +/** + * Options. + */ +export type PreferSwitchOptions = [PreferSwitchOption?]; + +/** + * Prefer `switch` over multiple `else-if`. + * + * @see [prefer-switch](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-switch.md) + */ +export type PreferSwitchRuleConfig = RuleConfig; + +/** + * Prefer `switch` over multiple `else-if`. + * + * @see [prefer-switch](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-switch.md) + */ +export interface PreferSwitchRule { + /** + * Prefer `switch` over multiple `else-if`. + * + * @see [prefer-switch](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-switch.md) + */ + 'unicorn/prefer-switch': PreferSwitchRuleConfig; +} diff --git a/src/rules/unicorn/prefer-ternary.d.ts b/src/rules/unicorn/prefer-ternary.d.ts new file mode 100644 index 00000000..52e27e49 --- /dev/null +++ b/src/rules/unicorn/prefer-ternary.d.ts @@ -0,0 +1,32 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export type PreferTernaryOption = 'always' | 'only-single-line'; + +/** + * Options. + */ +export type PreferTernaryOptions = [PreferTernaryOption?]; + +/** + * Prefer ternary expressions over simple `if-else` statements. + * + * @see [prefer-ternary](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-ternary.md) + */ +export type PreferTernaryRuleConfig = RuleConfig; + +/** + * Prefer ternary expressions over simple `if-else` statements. + * + * @see [prefer-ternary](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-ternary.md) + */ +export interface PreferTernaryRule { + /** + * Prefer ternary expressions over simple `if-else` statements. + * + * @see [prefer-ternary](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-ternary.md) + */ + 'unicorn/prefer-ternary': PreferTernaryRuleConfig; +} diff --git a/src/rules/unicorn/prefer-text-content.d.ts b/src/rules/unicorn/prefer-text-content.d.ts new file mode 100644 index 00000000..dc327b1a --- /dev/null +++ b/src/rules/unicorn/prefer-text-content.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-text-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-text-content) + */ +export type PreferTextContentRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-text-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-text-content) + */ +export interface PreferTextContentRule { + /** + * + * + * @deprecated + * + * @see [prefer-text-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-text-content) + */ + 'unicorn/prefer-text-content': PreferTextContentRuleConfig; +} diff --git a/src/rules/unicorn/prefer-top-level-await.d.ts b/src/rules/unicorn/prefer-top-level-await.d.ts new file mode 100644 index 00000000..4b893a9b --- /dev/null +++ b/src/rules/unicorn/prefer-top-level-await.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Prefer top-level await over top-level promises and async function calls. + * + * @see [prefer-top-level-await](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-top-level-await.md) + */ +export type PreferTopLevelAwaitRuleConfig = RuleConfig<[]>; + +/** + * Prefer top-level await over top-level promises and async function calls. + * + * @see [prefer-top-level-await](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-top-level-await.md) + */ +export interface PreferTopLevelAwaitRule { + /** + * Prefer top-level await over top-level promises and async function calls. + * + * @see [prefer-top-level-await](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-top-level-await.md) + */ + 'unicorn/prefer-top-level-await': PreferTopLevelAwaitRuleConfig; +} diff --git a/src/rules/unicorn/prefer-trim-start-end.d.ts b/src/rules/unicorn/prefer-trim-start-end.d.ts new file mode 100644 index 00000000..aed20896 --- /dev/null +++ b/src/rules/unicorn/prefer-trim-start-end.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [prefer-trim-start-end](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-trim-start-end) + */ +export type PreferTrimStartEndRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [prefer-trim-start-end](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-trim-start-end) + */ +export interface PreferTrimStartEndRule { + /** + * + * + * @deprecated + * + * @see [prefer-trim-start-end](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#prefer-trim-start-end) + */ + 'unicorn/prefer-trim-start-end': PreferTrimStartEndRuleConfig; +} diff --git a/src/rules/unicorn/prefer-type-error.d.ts b/src/rules/unicorn/prefer-type-error.d.ts new file mode 100644 index 00000000..fff4ece6 --- /dev/null +++ b/src/rules/unicorn/prefer-type-error.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce throwing `TypeError` in type checking conditions. + * + * @see [prefer-type-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-type-error.md) + */ +export type PreferTypeErrorRuleConfig = RuleConfig<[]>; + +/** + * Enforce throwing `TypeError` in type checking conditions. + * + * @see [prefer-type-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-type-error.md) + */ +export interface PreferTypeErrorRule { + /** + * Enforce throwing `TypeError` in type checking conditions. + * + * @see [prefer-type-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/prefer-type-error.md) + */ + 'unicorn/prefer-type-error': PreferTypeErrorRuleConfig; +} diff --git a/src/rules/unicorn/regex-shorthand.d.ts b/src/rules/unicorn/regex-shorthand.d.ts new file mode 100644 index 00000000..7971a216 --- /dev/null +++ b/src/rules/unicorn/regex-shorthand.d.ts @@ -0,0 +1,28 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * + * + * @deprecated + * + * @see [regex-shorthand](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#regex-shorthand) + */ +export type RegexShorthandRuleConfig = RuleConfig<[]>; + +/** + * + * + * @deprecated + * + * @see [regex-shorthand](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#regex-shorthand) + */ +export interface RegexShorthandRule { + /** + * + * + * @deprecated + * + * @see [regex-shorthand](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/deprecated-rules.md#regex-shorthand) + */ + 'unicorn/regex-shorthand': RegexShorthandRuleConfig; +} diff --git a/src/rules/unicorn/require-array-join-separator.d.ts b/src/rules/unicorn/require-array-join-separator.d.ts new file mode 100644 index 00000000..ddf1020f --- /dev/null +++ b/src/rules/unicorn/require-array-join-separator.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce using the separator argument with `Array#join()`. + * + * @see [require-array-join-separator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/require-array-join-separator.md) + */ +export type RequireArrayJoinSeparatorRuleConfig = RuleConfig<[]>; + +/** + * Enforce using the separator argument with `Array#join()`. + * + * @see [require-array-join-separator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/require-array-join-separator.md) + */ +export interface RequireArrayJoinSeparatorRule { + /** + * Enforce using the separator argument with `Array#join()`. + * + * @see [require-array-join-separator](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/require-array-join-separator.md) + */ + 'unicorn/require-array-join-separator': RequireArrayJoinSeparatorRuleConfig; +} diff --git a/src/rules/unicorn/require-number-to-fixed-digits-argument.d.ts b/src/rules/unicorn/require-number-to-fixed-digits-argument.d.ts new file mode 100644 index 00000000..f99d9eb7 --- /dev/null +++ b/src/rules/unicorn/require-number-to-fixed-digits-argument.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce using the digits argument with `Number#toFixed()`. + * + * @see [require-number-to-fixed-digits-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/require-number-to-fixed-digits-argument.md) + */ +export type RequireNumberToFixedDigitsArgumentRuleConfig = RuleConfig<[]>; + +/** + * Enforce using the digits argument with `Number#toFixed()`. + * + * @see [require-number-to-fixed-digits-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/require-number-to-fixed-digits-argument.md) + */ +export interface RequireNumberToFixedDigitsArgumentRule { + /** + * Enforce using the digits argument with `Number#toFixed()`. + * + * @see [require-number-to-fixed-digits-argument](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/require-number-to-fixed-digits-argument.md) + */ + 'unicorn/require-number-to-fixed-digits-argument': RequireNumberToFixedDigitsArgumentRuleConfig; +} diff --git a/src/rules/unicorn/require-post-message-target-origin.d.ts b/src/rules/unicorn/require-post-message-target-origin.d.ts new file mode 100644 index 00000000..bf4715fb --- /dev/null +++ b/src/rules/unicorn/require-post-message-target-origin.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Enforce using the `targetOrigin` argument with `window.postMessage()`. + * + * @see [require-post-message-target-origin](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/require-post-message-target-origin.md) + */ +export type RequirePostMessageTargetOriginRuleConfig = RuleConfig<[]>; + +/** + * Enforce using the `targetOrigin` argument with `window.postMessage()`. + * + * @see [require-post-message-target-origin](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/require-post-message-target-origin.md) + */ +export interface RequirePostMessageTargetOriginRule { + /** + * Enforce using the `targetOrigin` argument with `window.postMessage()`. + * + * @see [require-post-message-target-origin](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/require-post-message-target-origin.md) + */ + 'unicorn/require-post-message-target-origin': RequirePostMessageTargetOriginRuleConfig; +} diff --git a/src/rules/unicorn/string-content.d.ts b/src/rules/unicorn/string-content.d.ts new file mode 100644 index 00000000..518690a3 --- /dev/null +++ b/src/rules/unicorn/string-content.d.ts @@ -0,0 +1,42 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Option. + */ +export interface StringContentOption { + patterns?: { + [k: string]: + | string + | { + suggest: string; + fix?: boolean; + message?: string; + }; + }; +} + +/** + * Options. + */ +export type StringContentOptions = [StringContentOption?]; + +/** + * Enforce better string content. + * + * @see [string-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/string-content.md) + */ +export type StringContentRuleConfig = RuleConfig; + +/** + * Enforce better string content. + * + * @see [string-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/string-content.md) + */ +export interface StringContentRule { + /** + * Enforce better string content. + * + * @see [string-content](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/string-content.md) + */ + 'unicorn/string-content': StringContentRuleConfig; +} diff --git a/src/rules/unicorn/throw-new-error.d.ts b/src/rules/unicorn/throw-new-error.d.ts new file mode 100644 index 00000000..e76b8958 --- /dev/null +++ b/src/rules/unicorn/throw-new-error.d.ts @@ -0,0 +1,22 @@ +import type { RuleConfig } from '../rule-config'; + +/** + * Require `new` when throwing an error. + * + * @see [throw-new-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/throw-new-error.md) + */ +export type ThrowNewErrorRuleConfig = RuleConfig<[]>; + +/** + * Require `new` when throwing an error. + * + * @see [throw-new-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/throw-new-error.md) + */ +export interface ThrowNewErrorRule { + /** + * Require `new` when throwing an error. + * + * @see [throw-new-error](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v36.0.0/docs/rules/throw-new-error.md) + */ + 'unicorn/throw-new-error': ThrowNewErrorRuleConfig; +}