diff --git a/.eslintignore b/.eslintignore index 78329ed..4a31d34 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ -dist +./dist +./configs node_modules -jest.config.js +./jest.config.js diff --git a/.eslintrc.json b/.eslintrc.json index f444db0..58f030f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -57,6 +57,7 @@ "plugins": ["solid"], "extends": "plugin:solid/recommended", "rules": { + "@typescript-eslint/no-unused-vars": 0, "@typescript-eslint/ban-ts-comment": 0, "@typescript-eslint/no-empty-function": 0 } diff --git a/README.md b/README.md index 1e78789..043001c 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,17 @@ migrate some React patterns to Solid code. It's approaching a `1.0.0` release, and it's well tested and should be helpful in Solid projects today. + +- [Installation](#installation) +- [Configuration](#configuration) + - [TypeScript](#typescript) + - [Manual Configuration](#manual-configuration) + - [Flat Configuration](#flat-configuration) +- [Rules](#rules) +- [Troubleshooting](#troubleshooting) +- [Versioning](#versioning) + + ## Installation Install `eslint` and `eslint-plugin-solid` locally. @@ -100,25 +111,53 @@ options you can set. } ``` -## Flat Configuration +### Flat Configuration -The configurations are also available [Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files-new) objects. They use the `"files"` key to apply to their respective file extensions (`.js`, `.mjs` and `.jsx` for the recommended configuration; `.ts` and `.tsx` for the typescript configuration). Alternatively you can import `eslint-plugin-solid` directly for a manual configuration as described above. +ESLint's new configuration system, [Flat +Configuration](https://eslint.org/docs/latest/use/configure/configuration-files-new#using-configurations-included-in-plugins), +is available starting in ESLint [v8.23.0](https://github.com/eslint/eslint/releases/tag/v8.23.0). To +use it, create an `eslint.config.js` file at the root of your project, instead of `.eslintrc.*` +and/or `.eslintignore`. ```js import js from "@eslint/js"; -import solid from "eslint-plugin-solid/dist/configs/recommended.js"; -import solidTS from "eslint-plugin-solid/dist/configs/typescript.js"; +import solid from "eslint-plugin-solid/configs/recommended"; export default [ js.configs.recommended, // replaces eslint:recommended solid, - solidTS // optional ]; ``` -These configurations do not configure global variables in ESLint. You can do this yourself manually or with a package like [globals](https://www.npmjs.com/package/globals) by creating a configuration with a `languageOptions.globals` object. We recommend setting up global variables for Browser APIs as well as at least ES2015. +For TypeScript: -Note for VSCode Extension: Enable the "Use Flat Config" setting for your workspace to enable Flat Config support. +```js +import js from "@eslint/js"; +import solid from 'eslint-plugin-solid/configs/typescript'; +import * as tsParser from "@typescript-eslint/parser", + +export default [ + js.configs.recommended, + { + files: ["**/*.{ts,tsx}"], + ...solid, + languageOptions: { + parser: tsParser, + parserOptions: { + project: 'tsconfig.json', + }, + }, + }, +] +``` + +These configurations do not configure global variables in ESLint. You can do this yourself manually +or with a package like [globals](https://www.npmjs.com/package/globals) by creating a configuration +with a `languageOptions.globals` object. We recommend setting up global variables for Browser APIs +as well as at least ES2015. + +Note for the ESLint VSCode Extension: Enable the "Use Flat Config" setting for your workspace to +enable Flat Config support. ## Rules @@ -154,7 +193,7 @@ Note for VSCode Extension: Enable the "Use Flat Config" setting for your workspa ## Troubleshooting The rules in this plugin provide sensible guidelines as well as possible, but there may be times -where the you better than the rule and want to ignore a warning. Just [add a +where you know better than the rule and want to ignore a warning. To do that, [add a comment](https://eslint.org/docs/latest/user-guide/configuring/rules#disabling-rules) like the following: @@ -163,10 +202,13 @@ following: const [editedValue, setEditedValue] = createSignal(props.value); ``` -_However_, there may also be times where a rule correctly warns about a subtle problem, +_Please note_: there may also be times where a rule correctly warns about a subtle problem, even if it looks like a false positive at first. With `solid/reactivity`, please look at the [reactivity docs](./docs/reactivity.md#troubleshooting) before deciding to disable the rule. +When in doubt, feel free to [file an +issue](https://github.com/solidjs-community/eslint-plugin-solid/issues/new/choose). + ## Versioning Pre-1.0.0, the rules and the `recommended` and `typescript` configuations will be diff --git a/configs/recommended.d.ts b/configs/recommended.d.ts new file mode 100644 index 0000000..f4cb5db --- /dev/null +++ b/configs/recommended.d.ts @@ -0,0 +1,4 @@ +declare module "eslint-plugin-solid/configs/recommended" { + const config: typeof import("../src/configs/recommended"); + export = config; +} diff --git a/configs/recommended.js b/configs/recommended.js new file mode 100644 index 0000000..cbfd3a6 --- /dev/null +++ b/configs/recommended.js @@ -0,0 +1 @@ +module.exports = require("../dist/configs/recommended"); diff --git a/configs/typescript.d.ts b/configs/typescript.d.ts new file mode 100644 index 0000000..60a321e --- /dev/null +++ b/configs/typescript.d.ts @@ -0,0 +1,4 @@ +declare module "eslint-plugin-solid/configs/typescript" { + const config: typeof import("../src/configs/typescript"); + export = config; +} diff --git a/configs/typescript.js b/configs/typescript.js new file mode 100644 index 0000000..594ac8b --- /dev/null +++ b/configs/typescript.js @@ -0,0 +1 @@ +module.exports = require("../dist/configs/typescript"); diff --git a/package.json b/package.json index 9416c94..9e6dd6c 100644 --- a/package.json +++ b/package.json @@ -46,10 +46,11 @@ "devDependencies": { "@babel/core": "^7.21.3", "@babel/eslint-parser": "^7.21.3", + "@eslint/js": "^8.44.0", "@rollup/plugin-commonjs": "^22.0.2", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^14.1.0", - "@types/eslint": "^8.21.2", + "@types/eslint": "^8.40.2", "@types/fs-extra": "^9.0.13", "@types/is-html": "^2.0.0", "@types/jest": "^27.5.2", @@ -58,7 +59,7 @@ "@types/prettier": "^2.7.2", "@typescript-eslint/eslint-plugin": "^5.55.0", "@typescript-eslint/parser": "^5.55.0", - "eslint": "^8.36.0", + "eslint": "^8.43.0", "eslint-plugin-eslint-plugin": "^5.0.8", "eslint-plugin-import": "^2.27.5", "eslint-plugin-solid": "link:", @@ -74,7 +75,7 @@ "markdown-magic": "^2.6.1", "prettier": "^2.8.4", "rollup": "^2.79.1", - "ts-jest": "^29.0.5", + "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "typescript": "^5.0.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aa004b3..47a964b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3,10 +3,11 @@ lockfileVersion: 5.4 specifiers: '@babel/core': ^7.21.3 '@babel/eslint-parser': ^7.21.3 + '@eslint/js': ^8.44.0 '@rollup/plugin-commonjs': ^22.0.2 '@rollup/plugin-json': ^4.1.0 '@rollup/plugin-node-resolve': ^14.1.0 - '@types/eslint': ^8.21.2 + '@types/eslint': ^8.40.2 '@types/fs-extra': ^9.0.13 '@types/is-html': ^2.0.0 '@types/jest': ^27.5.2 @@ -16,7 +17,7 @@ specifiers: '@typescript-eslint/eslint-plugin': ^5.55.0 '@typescript-eslint/parser': ^5.55.0 '@typescript-eslint/utils': ^5.55.0 - eslint: ^8.36.0 + eslint: ^8.43.0 eslint-plugin-eslint-plugin: ^5.0.8 eslint-plugin-import: ^2.27.5 eslint-plugin-solid: 'link:' @@ -37,12 +38,12 @@ specifiers: prettier: ^2.8.4 rollup: ^2.79.1 style-to-object: ^0.3.0 - ts-jest: ^29.0.5 + ts-jest: ^29.1.1 ts-node: ^10.9.1 typescript: ^5.0.2 dependencies: - '@typescript-eslint/utils': 5.55.0_j4766f7ecgqbon3u7zlxn5zszu + '@typescript-eslint/utils': 5.55.0_uzfx6nkvnvrq5hklppufd63wbq is-html: 2.0.0 jsx-ast-utils: 3.3.3 kebab-case: 1.0.2 @@ -51,22 +52,23 @@ dependencies: devDependencies: '@babel/core': 7.21.3 - '@babel/eslint-parser': 7.21.3_pxuto7xgangxlusvzceggvrmde + '@babel/eslint-parser': 7.21.3_exgg4spdd6wmpabwf4vsye5g3m + '@eslint/js': 8.44.0 '@rollup/plugin-commonjs': 22.0.2_rollup@2.79.1 '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 14.1.0_rollup@2.79.1 - '@types/eslint': 8.21.2 + '@types/eslint': 8.40.2 '@types/fs-extra': 9.0.13 '@types/is-html': 2.0.0 '@types/jest': 27.5.2 '@types/markdown-magic': 1.0.1 '@types/node': 16.18.16 '@types/prettier': 2.7.2 - '@typescript-eslint/eslint-plugin': 5.55.0_qsnvknysi52qtaxqdyqyohkcku - '@typescript-eslint/parser': 5.55.0_j4766f7ecgqbon3u7zlxn5zszu - eslint: 8.36.0 - eslint-plugin-eslint-plugin: 5.0.8_eslint@8.36.0 - eslint-plugin-import: 2.27.5_a7er6olmtneep4uytpot6gt7wu + '@typescript-eslint/eslint-plugin': 5.55.0_wbufqjnpoyg7jdkfggfgvxf5dm + '@typescript-eslint/parser': 5.55.0_uzfx6nkvnvrq5hklppufd63wbq + eslint: 8.43.0 + eslint-plugin-eslint-plugin: 5.0.8_eslint@8.43.0 + eslint-plugin-import: 2.27.5_h5quhsklelcs6koiptafgkorli eslint-plugin-solid: 'link:' eslint-v6: /eslint/6.8.0 eslint-v7: /eslint/7.32.0 @@ -80,12 +82,17 @@ devDependencies: markdown-magic: 2.6.1 prettier: 2.8.4 rollup: 2.79.1 - ts-jest: 29.0.5_6tbz74k542pb7xqsa62i4fqrfq + ts-jest: 29.1.1_6tbz74k542pb7xqsa62i4fqrfq ts-node: 10.9.1_szaju5dhyuwhxrpyacxphv2gve typescript: 5.0.2 packages: + /@aashutoshrathi/word-wrap/1.2.6: + resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==} + engines: {node: '>=0.10.0'} + dev: true + /@ampproject/remapping/2.2.0: resolution: {integrity: sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==} engines: {node: '>=6.0.0'} @@ -97,7 +104,7 @@ packages: /@babel/code-frame/7.12.11: resolution: {integrity: sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==} dependencies: - '@babel/highlight': 7.18.6 + '@babel/highlight': 7.22.5 dev: true /@babel/code-frame/7.18.6: @@ -107,6 +114,13 @@ packages: '@babel/highlight': 7.18.6 dev: true + /@babel/code-frame/7.22.5: + resolution: {integrity: sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/highlight': 7.22.5 + dev: true + /@babel/compat-data/7.21.0: resolution: {integrity: sha512-gMuZsmsgxk/ENC3O/fRw5QY8A9/uxQbbCEypnLIiYYc/qVJtEV7ouxC3EllIIwNzMqAQee5tanFabWsUOutS7g==} engines: {node: '>=6.9.0'} @@ -135,7 +149,7 @@ packages: - supports-color dev: true - /@babel/eslint-parser/7.21.3_pxuto7xgangxlusvzceggvrmde: + /@babel/eslint-parser/7.21.3_exgg4spdd6wmpabwf4vsye5g3m: resolution: {integrity: sha512-kfhmPimwo6k4P8zxNs8+T7yR44q1LdpsZdE1NkCsVlfiuTPRfnGgjaF8Qgug9q9Pou17u6wneYF0lDCZJATMFg==} engines: {node: ^10.13.0 || ^12.13.0 || >=14.0.0} peerDependencies: @@ -144,7 +158,7 @@ packages: dependencies: '@babel/core': 7.21.3 '@nicolo-ribaudo/eslint-scope-5-internals': 5.1.1-v1 - eslint: 8.36.0 + eslint: 8.43.0 eslint-visitor-keys: 2.1.0 semver: 6.3.0 dev: true @@ -245,6 +259,11 @@ packages: engines: {node: '>=6.9.0'} dev: true + /@babel/helper-validator-identifier/7.22.5: + resolution: {integrity: sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==} + engines: {node: '>=6.9.0'} + dev: true + /@babel/helper-validator-option/7.21.0: resolution: {integrity: sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ==} engines: {node: '>=6.9.0'} @@ -270,6 +289,15 @@ packages: js-tokens: 4.0.0 dev: true + /@babel/highlight/7.22.5: + resolution: {integrity: sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-validator-identifier': 7.22.5 + chalk: 2.4.2 + js-tokens: 4.0.0 + dev: true + /@babel/parser/7.21.3: resolution: {integrity: sha512-lobG0d7aOfQRXh8AyklEAgZGvA4FShxo6xQbUrrT/cNBPUdIDojlokwJsQyCC/eKia7ifqM0yP+2DRZ4WKw2RQ==} engines: {node: '>=6.0.0'} @@ -454,14 +482,14 @@ packages: '@jridgewell/trace-mapping': 0.3.9 dev: true - /@eslint-community/eslint-utils/4.3.0_eslint@8.36.0: + /@eslint-community/eslint-utils/4.3.0_eslint@8.43.0: resolution: {integrity: sha512-v3oplH6FYCULtFuCeqyuTd9D2WKO937Dxdq+GmHOLL72TTRriLxz2VLlNfkZRsvj6PKnOPAtuT6dwrs/pA5DvA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.36.0 - eslint-visitor-keys: 3.3.0 + eslint: 8.43.0 + eslint-visitor-keys: 3.4.1 /@eslint-community/regexpp/4.4.0: resolution: {integrity: sha512-A9983Q0LnDGdLPjxyXQ00sbV+K+O+ko2Dr+CZigbHWtX9pNfxlaBkMR8X1CztI73zuEyEBXTVjx7CE+/VSwDiQ==} @@ -484,13 +512,13 @@ packages: - supports-color dev: true - /@eslint/eslintrc/2.0.1: - resolution: {integrity: sha512-eFRmABvW2E5Ho6f5fHLqgena46rOj7r7OKHYfLElqcBfGFHHpjBhivyi5+jOEQuSpdc/1phIZJlbC2te+tZNIw==} + /@eslint/eslintrc/2.0.3: + resolution: {integrity: sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 debug: 4.3.4 - espree: 9.5.0 + espree: 9.5.2 globals: 13.20.0 ignore: 5.2.4 import-fresh: 3.3.0 @@ -500,12 +528,17 @@ packages: transitivePeerDependencies: - supports-color - /@eslint/js/8.36.0: - resolution: {integrity: sha512-lxJ9R5ygVm8ZWgYdUweoq5ownDlJ4upvoWmO4eLxBYHdMo+vZ/Rx0EN6MbKWDJOSUGrqJy2Gt+Dyv/VKml0fjg==} + /@eslint/js/8.43.0: + resolution: {integrity: sha512-s2UHCoiXfxMvmfzqoN+vrQ84ahUSYde9qNO1MdxmoEhyHWsfmwOpFlwYV+ePJEVc7gFnATGUi376WowX1N7tFg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - /@humanwhocodes/config-array/0.11.8: - resolution: {integrity: sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==} + /@eslint/js/8.44.0: + resolution: {integrity: sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dev: true + + /@humanwhocodes/config-array/0.11.10: + resolution: {integrity: sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==} engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 1.2.1 @@ -986,8 +1019,8 @@ packages: '@types/node': 16.18.16 dev: true - /@types/eslint/8.21.2: - resolution: {integrity: sha512-EMpxUyystd3uZVByZap1DACsMXvb82ypQnGn89e1Y0a+LYu3JJscUd/gqhRsVFDkaD2MIiWo0MT8EfXr3DGRKw==} + /@types/eslint/8.40.2: + resolution: {integrity: sha512-PRVjQ4Eh9z9pmmtaq8nTjZjQwKFk7YIHIud3lRoKRBgUQjgjRmoGxxGEPXQkF+lH7QkHJRNr5F4aBgYCW0lqpQ==} dependencies: '@types/estree': 1.0.0 '@types/json-schema': 7.0.11 @@ -1125,7 +1158,7 @@ packages: '@types/yargs-parser': 21.0.0 dev: true - /@typescript-eslint/eslint-plugin/5.55.0_qsnvknysi52qtaxqdyqyohkcku: + /@typescript-eslint/eslint-plugin/5.55.0_wbufqjnpoyg7jdkfggfgvxf5dm: resolution: {integrity: sha512-IZGc50rtbjk+xp5YQoJvmMPmJEYoC53SiKPXyqWfv15XoD2Y5Kju6zN0DwlmaGJp1Iw33JsWJcQ7nw0lGCGjVg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1137,12 +1170,12 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.4.0 - '@typescript-eslint/parser': 5.55.0_j4766f7ecgqbon3u7zlxn5zszu + '@typescript-eslint/parser': 5.55.0_uzfx6nkvnvrq5hklppufd63wbq '@typescript-eslint/scope-manager': 5.55.0 - '@typescript-eslint/type-utils': 5.55.0_j4766f7ecgqbon3u7zlxn5zszu - '@typescript-eslint/utils': 5.55.0_j4766f7ecgqbon3u7zlxn5zszu + '@typescript-eslint/type-utils': 5.55.0_uzfx6nkvnvrq5hklppufd63wbq + '@typescript-eslint/utils': 5.55.0_uzfx6nkvnvrq5hklppufd63wbq debug: 4.3.4 - eslint: 8.36.0 + eslint: 8.43.0 grapheme-splitter: 1.0.4 ignore: 5.2.4 natural-compare-lite: 1.4.0 @@ -1153,7 +1186,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser/5.55.0_j4766f7ecgqbon3u7zlxn5zszu: + /@typescript-eslint/parser/5.55.0_uzfx6nkvnvrq5hklppufd63wbq: resolution: {integrity: sha512-ppvmeF7hvdhUUZWSd2EEWfzcFkjJzgNQzVST22nzg958CR+sphy8A6K7LXQZd6V75m1VKjp+J4g/PCEfSCmzhw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1167,7 +1200,7 @@ packages: '@typescript-eslint/types': 5.55.0 '@typescript-eslint/typescript-estree': 5.55.0_typescript@5.0.2 debug: 4.3.4 - eslint: 8.36.0 + eslint: 8.43.0 typescript: 5.0.2 transitivePeerDependencies: - supports-color @@ -1180,7 +1213,7 @@ packages: '@typescript-eslint/types': 5.55.0 '@typescript-eslint/visitor-keys': 5.55.0 - /@typescript-eslint/type-utils/5.55.0_j4766f7ecgqbon3u7zlxn5zszu: + /@typescript-eslint/type-utils/5.55.0_uzfx6nkvnvrq5hklppufd63wbq: resolution: {integrity: sha512-ObqxBgHIXj8rBNm0yh8oORFrICcJuZPZTqtAFh0oZQyr5DnAHZWfyw54RwpEEH+fD8suZaI0YxvWu5tYE/WswA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1191,9 +1224,9 @@ packages: optional: true dependencies: '@typescript-eslint/typescript-estree': 5.55.0_typescript@5.0.2 - '@typescript-eslint/utils': 5.55.0_j4766f7ecgqbon3u7zlxn5zszu + '@typescript-eslint/utils': 5.55.0_uzfx6nkvnvrq5hklppufd63wbq debug: 4.3.4 - eslint: 8.36.0 + eslint: 8.43.0 tsutils: 3.21.0_typescript@5.0.2 typescript: 5.0.2 transitivePeerDependencies: @@ -1218,25 +1251,25 @@ packages: debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 - semver: 7.3.8 + semver: 7.5.3 tsutils: 3.21.0_typescript@5.0.2 typescript: 5.0.2 transitivePeerDependencies: - supports-color - /@typescript-eslint/utils/5.55.0_j4766f7ecgqbon3u7zlxn5zszu: + /@typescript-eslint/utils/5.55.0_uzfx6nkvnvrq5hklppufd63wbq: resolution: {integrity: sha512-FkW+i2pQKcpDC3AY6DU54yl8Lfl14FVGYDgBTyGKB75cCwV3KpkpTMFi9d9j2WAJ4271LR2HeC5SEWF/CZmmfw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.3.0_eslint@8.36.0 + '@eslint-community/eslint-utils': 4.3.0_eslint@8.43.0 '@types/json-schema': 7.0.11 '@types/semver': 7.3.13 '@typescript-eslint/scope-manager': 5.55.0 '@typescript-eslint/types': 5.55.0 '@typescript-eslint/typescript-estree': 5.55.0_typescript@5.0.2 - eslint: 8.36.0 + eslint: 8.43.0 eslint-scope: 5.1.1 semver: 7.3.8 transitivePeerDependencies: @@ -1248,7 +1281,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: '@typescript-eslint/types': 5.55.0 - eslint-visitor-keys: 3.3.0 + eslint-visitor-keys: 3.4.1 /acorn-jsx/5.3.2_acorn@7.4.1: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} @@ -1258,12 +1291,12 @@ packages: acorn: 7.4.1 dev: true - /acorn-jsx/5.3.2_acorn@8.8.2: + /acorn-jsx/5.3.2_acorn@8.9.0: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - acorn: 8.8.2 + acorn: 8.9.0 /acorn-walk/8.2.0: resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==} @@ -1280,6 +1313,12 @@ packages: resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} engines: {node: '>=0.4.0'} hasBin: true + dev: true + + /acorn/8.9.0: + resolution: {integrity: sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==} + engines: {node: '>=0.4.0'} + hasBin: true /aggregate-error/3.1.0: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} @@ -2033,7 +2072,7 @@ packages: - supports-color dev: true - /eslint-module-utils/2.7.4_tzfhnsp6rhftjfsbnqrkrbah74: + /eslint-module-utils/2.7.4_waukb4zq4r3e3wqkelp4wjexki: resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==} engines: {node: '>=4'} peerDependencies: @@ -2054,26 +2093,26 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.55.0_j4766f7ecgqbon3u7zlxn5zszu + '@typescript-eslint/parser': 5.55.0_uzfx6nkvnvrq5hklppufd63wbq debug: 3.2.7 - eslint: 8.36.0 + eslint: 8.43.0 eslint-import-resolver-node: 0.3.7 transitivePeerDependencies: - supports-color dev: true - /eslint-plugin-eslint-plugin/5.0.8_eslint@8.36.0: + /eslint-plugin-eslint-plugin/5.0.8_eslint@8.43.0: resolution: {integrity: sha512-bxPMZ3L/+5YypErWQMKUI9XdkLpgqOOO0CgbtHjk5Zxzcg4EVsWYPy8duvGSLxSyR60LBIoXNzVMueEZ3/j0AQ==} engines: {node: ^14.17.0 || ^16.0.0 || >= 18.0.0} peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.36.0 - eslint-utils: 3.0.0_eslint@8.36.0 + eslint: 8.43.0 + eslint-utils: 3.0.0_eslint@8.43.0 estraverse: 5.3.0 dev: true - /eslint-plugin-import/2.27.5_a7er6olmtneep4uytpot6gt7wu: + /eslint-plugin-import/2.27.5_h5quhsklelcs6koiptafgkorli: resolution: {integrity: sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow==} engines: {node: '>=4'} peerDependencies: @@ -2083,15 +2122,15 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.55.0_j4766f7ecgqbon3u7zlxn5zszu + '@typescript-eslint/parser': 5.55.0_uzfx6nkvnvrq5hklppufd63wbq array-includes: 3.1.6 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 debug: 3.2.7 doctrine: 2.1.0 - eslint: 8.36.0 + eslint: 8.43.0 eslint-import-resolver-node: 0.3.7 - eslint-module-utils: 2.7.4_tzfhnsp6rhftjfsbnqrkrbah74 + eslint-module-utils: 2.7.4_waukb4zq4r3e3wqkelp4wjexki has: 1.0.3 is-core-module: 2.11.0 is-glob: 4.0.3 @@ -2113,8 +2152,8 @@ packages: esrecurse: 4.3.0 estraverse: 4.3.0 - /eslint-scope/7.1.1: - resolution: {integrity: sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==} + /eslint-scope/7.2.0: + resolution: {integrity: sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: esrecurse: 4.3.0 @@ -2134,13 +2173,13 @@ packages: eslint-visitor-keys: 1.3.0 dev: true - /eslint-utils/3.0.0_eslint@8.36.0: + /eslint-utils/3.0.0_eslint@8.43.0: resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} peerDependencies: eslint: '>=5' dependencies: - eslint: 8.36.0 + eslint: 8.43.0 eslint-visitor-keys: 2.1.0 dev: true @@ -2154,8 +2193,8 @@ packages: engines: {node: '>=10'} dev: true - /eslint-visitor-keys/3.3.0: - resolution: {integrity: sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==} + /eslint-visitor-keys/3.4.1: + resolution: {integrity: sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} /eslint/6.8.0: @@ -2163,7 +2202,7 @@ packages: engines: {node: ^8.10.0 || ^10.13.0 || >=11.10.1} hasBin: true dependencies: - '@babel/code-frame': 7.18.6 + '@babel/code-frame': 7.22.5 ajv: 6.12.6 chalk: 2.4.2 cross-spawn: 6.0.5 @@ -2240,10 +2279,10 @@ packages: lodash.merge: 4.6.2 minimatch: 3.1.2 natural-compare: 1.4.0 - optionator: 0.9.1 + optionator: 0.9.3 progress: 2.0.3 regexpp: 3.2.0 - semver: 7.3.8 + semver: 7.5.3 strip-ansi: 6.0.1 strip-json-comments: 3.1.1 table: 6.8.1 @@ -2253,16 +2292,16 @@ packages: - supports-color dev: true - /eslint/8.36.0: - resolution: {integrity: sha512-Y956lmS7vDqomxlaaQAHVmeb4tNMp2FWIvU/RnU5BD3IKMD/MJPr76xdyr68P8tV1iNMvN2mRK0yy3c+UjL+bw==} + /eslint/8.43.0: + resolution: {integrity: sha512-aaCpf2JqqKesMFGgmRPessmVKjcGXqdlAYLLC3THM8t5nBRZRQ+st5WM/hoJXkdioEXLLbXgclUpM0TXo5HX5Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint-community/eslint-utils': 4.3.0_eslint@8.36.0 + '@eslint-community/eslint-utils': 4.3.0_eslint@8.43.0 '@eslint-community/regexpp': 4.4.0 - '@eslint/eslintrc': 2.0.1 - '@eslint/js': 8.36.0 - '@humanwhocodes/config-array': 0.11.8 + '@eslint/eslintrc': 2.0.3 + '@eslint/js': 8.43.0 + '@humanwhocodes/config-array': 0.11.10 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 ajv: 6.12.6 @@ -2271,9 +2310,9 @@ packages: debug: 4.3.4 doctrine: 3.0.0 escape-string-regexp: 4.0.0 - eslint-scope: 7.1.1 - eslint-visitor-keys: 3.3.0 - espree: 9.5.0 + eslint-scope: 7.2.0 + eslint-visitor-keys: 3.4.1 + espree: 9.5.2 esquery: 1.5.0 esutils: 2.0.3 fast-deep-equal: 3.1.3 @@ -2281,13 +2320,12 @@ packages: find-up: 5.0.0 glob-parent: 6.0.2 globals: 13.20.0 - grapheme-splitter: 1.0.4 + graphemer: 1.4.0 ignore: 5.2.4 import-fresh: 3.3.0 imurmurhash: 0.1.4 is-glob: 4.0.3 is-path-inside: 3.0.3 - js-sdsl: 4.3.0 js-yaml: 4.1.0 json-stable-stringify-without-jsonify: 1.0.1 levn: 0.4.1 @@ -2319,13 +2357,13 @@ packages: eslint-visitor-keys: 1.3.0 dev: true - /espree/9.5.0: - resolution: {integrity: sha512-JPbJGhKc47++oo4JkEoTe2wjy4fmMwvFpgJT9cQzmfXKp22Dr6Hf1tdCteLz1h0P3t+mGvWZ+4Uankvh8+c6zw==} + /espree/9.5.2: + resolution: {integrity: sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - acorn: 8.8.2 - acorn-jsx: 5.3.2_acorn@8.8.2 - eslint-visitor-keys: 3.3.0 + acorn: 8.9.0 + acorn-jsx: 5.3.2_acorn@8.9.0 + eslint-visitor-keys: 3.4.1 /esprima/4.0.1: resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} @@ -2692,6 +2730,10 @@ packages: /grapheme-splitter/1.0.4: resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} + dev: true + + /graphemer/1.4.0: + resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} /has-bigints/1.0.2: resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} @@ -3317,7 +3359,7 @@ packages: resolution: {integrity: sha512-Kijeg9Dag6CKtIDA7O21zNTACqD5MD/8HfIV8pdD94vFyFuer52SigdC3IQMhab3vACxXMiFk+yMHNdbqtyTGA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: - '@babel/code-frame': 7.18.6 + '@babel/code-frame': 7.22.5 '@jest/types': 29.5.0 '@types/stack-utils': 2.0.1 chalk: 4.1.2 @@ -3468,7 +3510,7 @@ packages: jest-util: 29.5.0 natural-compare: 1.4.0 pretty-format: 29.5.0 - semver: 7.3.8 + semver: 7.5.3 transitivePeerDependencies: - supports-color dev: true @@ -3541,9 +3583,6 @@ packages: - ts-node dev: true - /js-sdsl/4.3.0: - resolution: {integrity: sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==} - /js-tokens/4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} dev: true @@ -4111,6 +4150,18 @@ packages: type-check: 0.4.0 word-wrap: 1.2.3 + /optionator/0.9.3: + resolution: {integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==} + engines: {node: '>= 0.8.0'} + dependencies: + '@aashutoshrathi/word-wrap': 1.2.6 + deep-is: 0.1.4 + fast-levenshtein: 2.0.6 + levn: 0.4.1 + prelude-ls: 1.2.1 + type-check: 0.4.0 + dev: true + /os-tmpdir/1.0.2: resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} engines: {node: '>=0.10.0'} @@ -4179,7 +4230,7 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} dependencies: - '@babel/code-frame': 7.18.6 + '@babel/code-frame': 7.22.5 error-ex: 1.3.2 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 @@ -4483,7 +4534,7 @@ packages: /rxjs/7.8.0: resolution: {integrity: sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==} dependencies: - tslib: 2.5.0 + tslib: 2.5.3 dev: true /safe-buffer/5.1.2: @@ -4522,6 +4573,13 @@ packages: dependencies: lru-cache: 6.0.0 + /semver/7.5.3: + resolution: {integrity: sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==} + engines: {node: '>=10'} + hasBin: true + dependencies: + lru-cache: 6.0.0 + /shebang-command/1.2.0: resolution: {integrity: sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==} engines: {node: '>=0.10.0'} @@ -4848,8 +4906,8 @@ packages: resolution: {integrity: sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==} dev: true - /ts-jest/29.0.5_6tbz74k542pb7xqsa62i4fqrfq: - resolution: {integrity: sha512-PL3UciSgIpQ7f6XjVOmbi96vmDHUqAyqDr8YxzopDqX3kfgYtX1cuNeBjP+L9sFXi6nzsGGA6R3fP3DDDJyrxA==} + /ts-jest/29.1.1_6tbz74k542pb7xqsa62i4fqrfq: + resolution: {integrity: sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true peerDependencies: @@ -4858,7 +4916,7 @@ packages: babel-jest: ^29.0.0 esbuild: '*' jest: ^29.0.0 - typescript: '>=4.3' + typescript: '>=4.3 <6' peerDependenciesMeta: '@babel/core': optional: true @@ -4877,7 +4935,7 @@ packages: json5: 2.2.3 lodash.memoize: 4.1.2 make-error: 1.3.6 - semver: 7.3.8 + semver: 7.5.3 typescript: 5.0.2 yargs-parser: 21.1.1 dev: true @@ -4925,8 +4983,8 @@ packages: /tslib/1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} - /tslib/2.5.0: - resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==} + /tslib/2.5.3: + resolution: {integrity: sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==} dev: true /tsutils/3.21.0_typescript@5.0.2: diff --git a/src/configs/recommended.ts b/src/configs/recommended.ts index ed64c81..ef7f9c4 100644 --- a/src/configs/recommended.ts +++ b/src/configs/recommended.ts @@ -1,7 +1,6 @@ import { plugin } from "../plugin"; const recommended = { - files: ["**/*.js?(x)", "**/*.mjs"], plugins: { solid: plugin, }, diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts index 0acdc59..7bc2537 100644 --- a/src/configs/typescript.ts +++ b/src/configs/typescript.ts @@ -1,24 +1,18 @@ -import { plugin } from "../plugin"; import recommended from "./recommended"; const typescript = { - files: ["**/*.ts?(x)"], - plugins: { - solid: plugin, - }, - languageOptions: { - sourceType: "module", - parserOptions: { - ecmaFeatures: { - jsx: true, - }, - }, - }, - rules: Object.assign({}, recommended.rules, { + // no files; either apply to all files, or let users spread in this config + // and specify matching patterns. This is eslint-plugin-react's take. + plugins: recommended.plugins, + // no languageOptions; ESLint's default parser can't parse TypeScript, + // and parsers are configured in languageOptions, so let the user handle + // this rather than cause potential conflicts + rules: { + ...recommended.rules, "solid/jsx-no-undef": [2, { typescriptEnabled: true }], // namespaces taken care of by TS "solid/no-unknown-namespaces": 0, - }), + }, }; export = typescript; diff --git a/src/index.ts b/src/index.ts index 4de9762..3dd9018 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,9 +13,7 @@ const pluginLegacy = { browser: true, es6: true, }, - parserOptions: Object.assign({}, recommendedConfig.languageOptions.parserOptions, { - sourceType: "module", - }), + parserOptions: recommendedConfig.languageOptions.parserOptions, rules: recommendedConfig.rules, }, typescript: { @@ -24,9 +22,9 @@ const pluginLegacy = { browser: true, es6: true, }, - parserOptions: Object.assign({}, typescriptConfig.languageOptions.parserOptions, { + parserOptions: { sourceType: "module", - }), + }, rules: typescriptConfig.rules, }, }, diff --git a/test/fixture.test.ts b/test/fixture.test.ts index 41db449..9a3a0fb 100644 --- a/test/fixture.test.ts +++ b/test/fixture.test.ts @@ -1,40 +1,68 @@ import path from "path"; -import glob from "fast-glob"; import { ESLint } from "eslint"; +// @ts-expect-error Type definitions not updated to include FlatESLint +import { FlatESLint } from "eslint/use-at-your-own-risk"; -const getTestFiles = () => { - const root = path.join("test", "fixture"); - return glob("**/*.{js,jsx,ts,tsx}", { cwd: root, absolute: true }); -}; +import * as tsParser from "@typescript-eslint/parser"; +import recommendedConfig from "eslint-plugin-solid/configs/recommended"; +import typescriptConfig from "eslint-plugin-solid/configs/typescript"; + +const cwd = path.resolve("test", "fixture"); +const validDir = path.join(cwd, "valid"); +const jsxUndefPath = path.join(cwd, "invalid", "jsx-undef.jsx"); + +const checkResult = (result: ESLint.LintResult) => { + if (result.filePath.startsWith(validDir)) { + expect(result.messages).toEqual([]); + expect(result.errorCount).toBe(0); + expect(result.warningCount).toBe(0); + expect(result.usedDeprecatedRules).toEqual([]); + } else { + expect(result.messages).not.toEqual([]); + expect(result.warningCount + result.errorCount).toBeGreaterThan(0); + expect(result.usedDeprecatedRules).toEqual([]); -const validDir = path.resolve("test", "fixture", "valid"); -const jsxUndefPath = path.resolve("test", "fixture", "invalid", "jsx-undef.jsx"); - -test("fixture", async () => { - const files = await getTestFiles(); - - const eslint = new ESLint(); - const results = await eslint.lintFiles(files); - - for (const result of results) { - if (result.filePath.startsWith(validDir)) { - expect(result.messages).toEqual([]); - expect(result.errorCount).toBe(0); - expect(result.warningCount).toBe(0); - expect(result.usedDeprecatedRules).toEqual([]); - } else { - expect(result.messages).not.toEqual([]); - expect(result.warningCount + result.errorCount).toBeGreaterThan(0); - expect(result.usedDeprecatedRules).toEqual([]); - - if (result.filePath === jsxUndefPath) { - // test for one specific error message - expect( - result.messages.some((message) => /'Component' is not defined/.test(message.message)) - ); - } + if (result.filePath === jsxUndefPath) { + // test for one specific error message + expect(result.messages.some((message) => /'Component' is not defined/.test(message.message))); } } +}; + +test.concurrent("fixture", async () => { + const eslint = new ESLint({ cwd }); + const results = await eslint.lintFiles("**/*.{js,jsx,ts,tsx}"); + + results.forEach(checkResult); + + expect(results.filter((result) => result.filePath === jsxUndefPath).length).toBe(1); +}); + +test.concurrent("fixture (flat)", async () => { + const eslint = new FlatESLint({ + cwd, + overrideConfigFile: true, + ignore: false, + overrideConfig: [ + { + files: ["**/*.{js,jsx}"], + ...recommendedConfig, + }, + { + files: ["**/*.{ts,tsx}"], + ...typescriptConfig, + languageOptions: { + parser: tsParser, + parserOptions: { + project: "tsconfig.json", + }, + }, + }, + ], + }); + const results: Array = await eslint.lintFiles("**/*.{js,jsx,ts,tsx}"); + + results.forEach(checkResult); expect(results.filter((result) => result.filePath === jsxUndefPath).length).toBe(1); }); diff --git a/test/fixture/invalid/jsx-undef.jsx b/test/fixture/invalid/jsx-undef.jsx index 75be34b..b9d2448 100644 --- a/test/fixture/invalid/jsx-undef.jsx +++ b/test/fixture/invalid/jsx-undef.jsx @@ -1,2 +1 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars let el = ; diff --git a/test/fixture/valid/examples/simple-todos.tsx b/test/fixture/valid/examples/simple-todos.tsx index 8371813..2915137 100644 --- a/test/fixture/valid/examples/simple-todos.tsx +++ b/test/fixture/valid/examples/simple-todos.tsx @@ -4,7 +4,6 @@ import { createStore, SetStoreFunction, Store } from "solid-js/store"; import { render } from "solid-js/web"; // Checked but not used for demo purposes -// eslint-disable-next-line @typescript-eslint/no-unused-vars function createLocalStore(initState: T): [Store, SetStoreFunction] { const [state, setState] = createStore(initState); if (localStorage.todos) setState(JSON.parse(localStorage.todos)); diff --git a/tsconfig.build.json b/tsconfig.build.json index c3dc159..e612a1f 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,6 +1,6 @@ { "extends": "./tsconfig.json", - "exclude": ["test", "scripts", "standalone", "jest.setup.js"], + "exclude": ["configs", "test", "scripts", "standalone", "jest.setup.js"], "compilerOptions": { "removeComments": true } diff --git a/tsconfig.json b/tsconfig.json index d312a09..109d55a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,11 +14,5 @@ "allowJs": true, "preserveSymlinks": true }, - "include": [ - "src", - "test", - "scripts", - "standalone", - "jest.setup.js" - ] + "include": ["src", "configs", "test", "scripts", "standalone", "jest.setup.js"] }