diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index ff56a13d2..000000000 --- a/.eslintignore +++ /dev/null @@ -1,9 +0,0 @@ -node_modules -cjs -esm -umd -dist -fixtures -packages/create-stylable-app/template -packages/create-stylable-app/typings/template.d.ts -packages/runtime/stylesheet.d.ts diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index cefe00d6d..000000000 --- a/.eslintrc +++ /dev/null @@ -1,67 +0,0 @@ -{ - "env": { - "browser": true, - "es2020": true, - "node": true - }, - "extends": ["eslint:recommended", "prettier"], - "parserOptions": { - "sourceType": "module" - }, - "rules": { - // "no-console": "error" - }, - "overrides": [ - { - "files": ["*.ts", "*.tsx"], - "parserOptions": { - "projectService": true - }, - "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking" - ], - "rules": { - "@typescript-eslint/no-unused-vars": [ - "error", - { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" } - ], - "@typescript-eslint/ban-types": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-var-requires": "off", - "@typescript-eslint/prefer-regexp-exec": "off", - "@typescript-eslint/restrict-plus-operands": "off", - "@typescript-eslint/restrict-template-expressions": "off", - "@typescript-eslint/unbound-method": "off", - "@typescript-eslint/no-unused-expressions": "off", - "@typescript-eslint/no-empty-object-type": "off", - "@typescript-eslint/no-require-imports": "off", - "@typescript-eslint/no-misused-promises": "off", // ToDo: remove once eslint fix issue. - "@typescript-eslint/no-base-to-string": "off" // this rule is not working properly - } - }, - { - "files": ["*.ts", "*.tsx"], - "excludedFiles": ["packages/*/test/**/*.ts"], - "rules": { - "no-restricted-imports": [ - "error", - { - "patterns": [ - "@stylable/*/src/*", - "@stylable/*/dist/*", - "!@stylable/*/dist/index-internal" - ] - } - ] - } - } - ] -} diff --git a/.mocharc.js b/.mocharc.js index 632f0266e..902a4e1eb 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -19,8 +19,8 @@ function getRequire() { 'experimental-loader', ]; - for (const package of packages) { - packagesSet.add(dirname(require.resolve(`@stylable/${package}/package.json`))); + for (const packageName of packages) { + packagesSet.add(dirname(require.resolve(`@stylable/${packageName}/package.json`))); } // we get this env variable from ./.vscode/launch.json (f5 - Mocha Current) diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..61eac3b23 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,55 @@ +import pluginJs from '@eslint/js'; +import configPrettier from 'eslint-config-prettier'; +import pluginTypescript from 'typescript-eslint'; + +for (const config of pluginTypescript.configs.recommendedTypeChecked) { + config.files = ['**/*.{ts,tsx,mts,cts}']; // ensure config only targets TypeScript files +} + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + { + ignores: [ + '**/dist/', + '**/esm/', + 'packages/create-stylable-app/typings/template.d.ts', + 'packages/language-service/test/fixtures/server-cases/mixins/', + 'packages/runtime/stylesheet.d.ts', + ], + }, + pluginJs.configs.recommended, + { + rules: { + 'no-console': 'off', + 'no-undef': 'off', + 'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], + }, + }, + ...pluginTypescript.configs.recommendedTypeChecked, + { languageOptions: { parserOptions: { projectService: true } } }, + { + files: ['**/*.{ts,tsx,mts,cts}'], + rules: { + '@typescript-eslint/no-base-to-string': 'off', + '@typescript-eslint/no-empty-object-type': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-require-imports': 'off', + + '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-return': 'off', + + '@typescript-eslint/no-unused-expressions': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, + ], + '@typescript-eslint/restrict-plus-operands': 'off', + '@typescript-eslint/restrict-template-expressions': 'off', + '@typescript-eslint/unbound-method': 'off', + }, + }, + configPrettier, +]; diff --git a/package-lock.json b/package-lock.json index 43bffce33..52a2093e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "packages/*" ], "devDependencies": { + "@eslint/js": "^9.9.1", "@file-services/memory": "^9.4.1", "@file-services/node": "^9.4.1", "@file-services/path": "^9.4.1", @@ -32,12 +33,10 @@ "@types/mocha": "^10.0.7", "@types/node": "18", "@types/postcss-safe-parser": "^5.0.4", - "@types/react": "^18.3.4", + "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", "@types/validate-npm-package-name": "^4.0.2", "@types/yargs": "^17.0.33", - "@typescript-eslint/eslint-plugin": "^8.3.0", - "@typescript-eslint/parser": "^8.3.0", "@typescript-eslint/rule-tester": "^8.3.0", "autoprefixer": "^10.4.20", "c8": "^10.1.2", @@ -46,7 +45,7 @@ "create-listening-server": "^2.1.0", "css-loader": "^7.1.2", "esbuild": "^0.23.1", - "eslint": "^8.57.0", + "eslint": "^9.9.1", "eslint-config-prettier": "^9.1.0", "file-loader": "^6.2.0", "html-webpack-plugin": "^5.6.0", @@ -70,6 +69,7 @@ "ts-expect": "^1.3.0", "tsconfig-paths-webpack-plugin": "^4.1.0", "typescript": "~5.5.4", + "typescript-eslint": "^8.3.0", "url-loader": "^4.1.1", "webpack": "^5.94.0", "yargs": "^17.7.2" @@ -493,16 +493,52 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint/config-array": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", + "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/config-array/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", + "espree": "^10.0.1", + "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -510,7 +546,7 @@ "strip-json-comments": "^3.1.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -539,12 +575,21 @@ } }, "node_modules/@eslint/js": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", - "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "version": "9.9.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.9.1.tgz", + "integrity": "sha512-xIDQRsfg5hNBqHz04H1R3scSVwmI+KUbqjsQKHKQ1DAUSaUjYPReZZmS/5PNiKu1fUvzDd6H7DEDKACSEhu+TQ==", "license": "MIT", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@file-services/memory": { @@ -589,18 +634,6 @@ "type-fest": "^4.23.0" } }, - "node_modules/@file-services/resolve/node_modules/type-fest": { - "version": "4.26.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.0.tgz", - "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@file-services/types": { "version": "9.4.1", "resolved": "https://registry.npmjs.org/@file-services/types/-/types-9.4.1.tgz", @@ -628,43 +661,6 @@ "@file-services/types": "^9.4.1" } }, - "node_modules/@humanwhocodes/config-array": { - "version": "0.11.14", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", - "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", - "deprecated": "Use @eslint/config-array instead", - "license": "Apache-2.0", - "dependencies": { - "@humanwhocodes/object-schema": "^2.0.2", - "debug": "^4.3.1", - "minimatch": "^3.0.5" - }, - "engines": { - "node": ">=10.10.0" - } - }, - "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -678,12 +674,18 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", - "deprecated": "Use @eslint/object-schema instead", - "license": "BSD-3-Clause" + "node_modules/@humanwhocodes/retry": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.0.tgz", + "integrity": "sha512-d2CGZR2o7fS6sWB7DG/3a95bGKQyHMACZ5aW8qGkkqQpUoZV6C0X7Pc7l4ZNMZkfNBf4VWNe9E1jRsf0G146Ew==", + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } }, "node_modules/@isaacs/cliui": { "version": "8.0.2", @@ -1458,9 +1460,9 @@ "license": "MIT" }, "node_modules/@types/react": { - "version": "18.3.4", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.4.tgz", - "integrity": "sha512-J7W30FTdfCxDDjmfRM+/JqLHBIyl7xUIp9kwK637FGmY7+mkSFSe6L4jpZzhj5QMfLssSDP4/i75AKkrdC7/Jw==", + "version": "18.3.5", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.5.tgz", + "integrity": "sha512-WeqMfGJLGuLCqHGYRGHxnKrXcTitc6L/nBUWfWPcTarG3t9PsquqUMuVeXZeca+mglY4Vo5GZjCi0A3Or2lnxA==", "dev": true, "license": "MIT", "dependencies": { @@ -1719,12 +1721,6 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@ungap/structured-clone": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", - "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", - "license": "ISC" - }, "node_modules/@vscode/l10n": { "version": "0.0.18", "resolved": "https://registry.npmjs.org/@vscode/l10n/-/l10n-0.0.18.tgz", @@ -1890,18 +1886,6 @@ "node": ">=16" } }, - "node_modules/@wixc3/resolve-directory-context/node_modules/type-fest": { - "version": "4.26.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.0.tgz", - "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@xtuc/ieee754": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", @@ -2917,18 +2901,6 @@ "node": ">=0.3.1" } }, - "node_modules/doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", - "license": "Apache-2.0", - "dependencies": { - "esutils": "^2.0.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/dom-converter": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", @@ -3309,41 +3281,37 @@ } }, "node_modules/eslint": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", - "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", + "version": "9.9.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.9.1.tgz", + "integrity": "sha512-dHvhrbfr4xFQ9/dq+jcVneZMyRYLjggWjk6RVsIiHsP8Rz6yZ8LvZ//iU4TrZF+SXWG+JkNF2OyiZRvzgRDqMg==", "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.0", - "@humanwhocodes/config-array": "^0.11.14", + "@eslint-community/regexpp": "^4.11.0", + "@eslint/config-array": "^0.18.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "9.9.1", "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.3.0", "@nodelib/fs.walk": "^1.2.8", - "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", - "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1", - "esquery": "^1.4.2", + "eslint-scope": "^8.0.2", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.1.0", + "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", + "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "graphemer": "^1.4.0", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", @@ -3357,10 +3325,18 @@ "eslint": "bin/eslint.js" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://opencollective.com/eslint" + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } } }, "node_modules/eslint-config-prettier": { @@ -3381,16 +3357,16 @@ "link": true }, "node_modules/eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.2.tgz", + "integrity": "sha512-6E4xmrTw5wtxnLA5wYL3WDfhZ/1bUBGOXV0zQvVRDOtrR8D0p6W7fs3JweNYhwRYeGvd/1CKX2se0/2s7Q/nJA==", "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -3418,6 +3394,18 @@ "concat-map": "0.0.1" } }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/eslint/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3431,17 +3419,29 @@ } }, "node_modules/espree": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", - "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", + "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.9.0", + "acorn": "^8.12.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.1" + "eslint-visitor-keys": "^4.0.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -3574,15 +3574,15 @@ } }, "node_modules/file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", "license": "MIT", "dependencies": { - "flat-cache": "^3.0.4" + "flat-cache": "^4.0.0" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": ">=16.0.0" } }, "node_modules/file-loader": { @@ -3656,76 +3656,16 @@ } }, "node_modules/flat-cache": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", - "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", "license": "MIT", "dependencies": { "flatted": "^3.2.9", - "keyv": "^4.5.3", - "rimraf": "^3.0.2" - }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "node_modules/flat-cache/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/flat-cache/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "keyv": "^4.5.4" }, "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/flat-cache/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/flat-cache/node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "deprecated": "Rimraf versions prior to v4 are no longer supported", - "license": "ISC", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "node": ">=16" } }, "node_modules/flatted": { @@ -3778,6 +3718,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, "license": "ISC" }, "node_modules/fsevents": { @@ -3942,15 +3883,12 @@ } }, "node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "license": "MIT", - "dependencies": { - "type-fest": "^0.20.2" - }, "engines": { - "node": ">=8" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -3996,6 +3934,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true, "license": "MIT" }, "node_modules/has-bigints": { @@ -4248,6 +4187,7 @@ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, "license": "ISC", "dependencies": { "once": "^1.3.0", @@ -4258,6 +4198,7 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, "license": "ISC" }, "node_modules/ini": { @@ -5960,6 +5901,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "license": "ISC", "dependencies": { "wrappy": "1" @@ -7453,12 +7395,12 @@ } }, "node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "version": "4.26.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.0.tgz", + "integrity": "sha512-OduNjVJsFbifKb57UqZ2EMP1i4u64Xwow3NYXUtBbD4vIwJdQd4+xl8YDou1dlm4DVrtwT/7Ky8z8WyCULVfxw==", "license": "(MIT OR CC0-1.0)", "engines": { - "node": ">=10" + "node": ">=16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -7554,6 +7496,30 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.3.0.tgz", + "integrity": "sha512-EvWjwWLwwKDIJuBjk2I6UkV8KEQcwZ0VM10nR1rIunRDIP67QJTZAHBXTX0HW/oI1H10YESF8yWie8fRQxjvFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.3.0", + "@typescript-eslint/parser": "8.3.0", + "@typescript-eslint/utils": "8.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/unbox-primitive": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", @@ -7973,6 +7939,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, "license": "ISC" }, "node_modules/y18n": { diff --git a/package.json b/package.json index d6a759d72..625bf6dfe 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "tsc --build && node scripts/build.js", "build:dev": "tsc --build", "watch": "tsc --build -w", - "lint": "eslint .", + "lint": "eslint", "pretest": "npm run build", "test": "node --enable-source-maps scripts/test-runner.js --parallel", "test:integrations": "npm run test -- --i", @@ -18,6 +18,7 @@ "prettify": "npx prettier . --write" }, "devDependencies": { + "@eslint/js": "^9.9.1", "@file-services/memory": "^9.4.1", "@file-services/node": "^9.4.1", "@file-services/path": "^9.4.1", @@ -40,12 +41,10 @@ "@types/mocha": "^10.0.7", "@types/node": "18", "@types/postcss-safe-parser": "^5.0.4", - "@types/react": "^18.3.4", + "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", "@types/validate-npm-package-name": "^4.0.2", "@types/yargs": "^17.0.33", - "@typescript-eslint/eslint-plugin": "^8.3.0", - "@typescript-eslint/parser": "^8.3.0", "@typescript-eslint/rule-tester": "^8.3.0", "autoprefixer": "^10.4.20", "c8": "^10.1.2", @@ -54,7 +53,7 @@ "create-listening-server": "^2.1.0", "css-loader": "^7.1.2", "esbuild": "^0.23.1", - "eslint": "^8.57.0", + "eslint": "^9.9.1", "eslint-config-prettier": "^9.1.0", "file-loader": "^6.2.0", "html-webpack-plugin": "^5.6.0", @@ -78,6 +77,7 @@ "ts-expect": "^1.3.0", "tsconfig-paths-webpack-plugin": "^4.1.0", "typescript": "~5.5.4", + "typescript-eslint": "^8.3.0", "url-loader": "^4.1.1", "webpack": "^5.94.0", "yargs": "^17.7.2" diff --git a/packages/core/src/features/css-custom-property.ts b/packages/core/src/features/css-custom-property.ts index 8094ca4e1..6a6eb851e 100644 --- a/packages/core/src/features/css-custom-property.ts +++ b/packages/core/src/features/css-custom-property.ts @@ -296,7 +296,6 @@ export function addCSSProperty({ if (existing) { // already defined return; - // eslint-disable-next-line no-constant-condition } else if (context.meta.type === 'stylable' && context.meta.flags.strictCustomProperty) { // strict mode context.diagnostics.report(diagnostics.UNDEFINED_CSS_CUSTOM_PROP(name), { diff --git a/packages/eslint-plugin-stylable/src/stylable-es-lint.ts b/packages/eslint-plugin-stylable/src/stylable-es-lint.ts index cff184b77..c15991bc1 100644 --- a/packages/eslint-plugin-stylable/src/stylable-es-lint.ts +++ b/packages/eslint-plugin-stylable/src/stylable-es-lint.ts @@ -56,7 +56,7 @@ export default createRule({ if (!importRequest) { return; } - const fileName = context.getFilename(); + const fileName = context.filename; const dirName = path.dirname(fileName); const fullPath = moduleResolver(dirName, importRequest); const meta = stylable.analyze(fullPath); @@ -74,15 +74,18 @@ export default createRule({ const exportName = imported.name as keyof typeof exports; if (exportName in exports) { - const variable = context.getScope().variables.find((varDefs) => { - if (varDefs.defs.length === 0) { - return; - } - const { type } = varDefs.defs[varDefs.defs.length - 1]; - return ( - local.name === varDefs.name && type === DefinitionType.ImportBinding - ); - }); + const variable = context.sourceCode + .getScope(node) + .variables.find((varDefs) => { + if (varDefs.defs.length === 0) { + return; + } + const { type } = varDefs.defs[varDefs.defs.length - 1]; + return ( + local.name === varDefs.name && + type === DefinitionType.ImportBinding + ); + }); if (!variable) { return; @@ -145,7 +148,6 @@ function getStylableRequest(importStatement: esTree.ImportDeclaration) { } function getMemberAccessor( - // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents property: esTree.PrivateIdentifier | esTree.Expression, isComputed: boolean, ) { diff --git a/packages/eslint-plugin-stylable/test/stylable-es-lint.spec.ts b/packages/eslint-plugin-stylable/test/stylable-es-lint.spec.ts index b8a9a7bc1..3108b9d67 100644 --- a/packages/eslint-plugin-stylable/test/stylable-es-lint.spec.ts +++ b/packages/eslint-plugin-stylable/test/stylable-es-lint.spec.ts @@ -1,102 +1,75 @@ -import path from 'path'; -import fs from 'fs'; -import eslintParser from '@typescript-eslint/parser'; import { RuleTester } from '@typescript-eslint/rule-tester'; import StylableLint from 'eslint-plugin-stylable/rule'; -import { createTempDirectorySync } from '@stylable/e2e-test-kit'; +import { fileURLToPath } from 'node:url'; + // mock afterAll for RuleTester (should be fixed in next version) (globalThis as any).afterAll = (globalThis as any).after; -const tester = new RuleTester({ - languageOptions: { - parser: eslintParser, - sourceType: 'module', - }, -}); - -const tmp = createTempDirectorySync('stylable-eslint'); -const filename = path.join(tmp.path, 'index.ts'); +const filename = fileURLToPath(new URL('../../test/stylesheet-user.ts', import.meta.url)); -fs.writeFileSync( - path.join(tmp.path, 'index.st.css'), - ` -:vars { - key: "value"; -} -.root { - --cssVar: green; - color: red; -} - -@keyframes test {} -`, -); - -after(() => { - tmp.remove(); -}); +const tester = new RuleTester(); tester.run('basic unknown locals discovery', StylableLint, { invalid: [ { filename, - code: "import {classes as XYZ} from './index.st.css'; const a = XYZ.part", + code: "import {classes as XYZ} from './stylesheet.st.css'; const a = XYZ.part", errors: [{ messageId: 'unknown-local' }], }, { filename, - code: "import {classes as XYZ} from './index.st.css'; const a = XYZ['part']", + code: "import {classes as XYZ} from './stylesheet.st.css'; const a = XYZ['part']", errors: [{ messageId: 'unknown-local' }], }, { filename, - code: "import {classes as XYZ} from './index.st.css'; ()=> {const a = XYZ.part}", + code: "import {classes as XYZ} from './stylesheet.st.css'; ()=> {const a = XYZ.part}", errors: [{ messageId: 'unknown-local' }], }, { filename, - code: "import {keyframes as XYZ} from './index.st.css'; const a = XYZ.part", + code: "import {keyframes as XYZ} from './stylesheet.st.css'; const a = XYZ.part", errors: [{ messageId: 'unknown-local' }], }, { filename, - code: "import {vars as XYZ} from './index.st.css'; const a = XYZ.part", + code: "import {vars as XYZ} from './stylesheet.st.css'; const a = XYZ.part", errors: [{ messageId: 'unknown-local' }], }, { filename, - code: "import {stVars as XYZ} from './index.st.css'; const a = XYZ.part", + code: "import {stVars as XYZ} from './stylesheet.st.css'; const a = XYZ.part", errors: [{ messageId: 'unknown-local' }], }, ], valid: [ { filename, - code: "import {classes as XYZ} from './index.st.css'; const a = XYZ.root", + code: "import {classes as XYZ} from './stylesheet.st.css'; const a = XYZ.root", }, { filename, - code: "import {classes as XYZ} from './index.st.css'; (XYZ)=> {const a = XYZ.part}", + code: "import {classes as XYZ} from './stylesheet.st.css'; (XYZ)=> {const a = XYZ.part}", }, { filename, - code: "import {classes as XYZ} from './index.st.css'; const a = XYZ['root']", + code: "import {classes as XYZ} from './stylesheet.st.css'; const a = XYZ['root']", }, { filename, - code: "import {classes as XYZ} from './index.st.css'; const x = ''; const a = XYZ[x]", + code: "import {classes as XYZ} from './stylesheet.st.css'; const x = ''; const a = XYZ[x]", }, { filename, - code: "import {keyframes as XYZ} from './index.st.css'; const a = XYZ.test", + code: "import {keyframes as XYZ} from './stylesheet.st.css'; const a = XYZ.test", }, { filename, - code: "import {vars as XYZ} from './index.st.css'; const a = XYZ.cssVar", + code: "import {vars as XYZ} from './stylesheet.st.css'; const a = XYZ.cssVar", }, { filename, - code: "import {stVars as XYZ} from './index.st.css'; const a = XYZ.key", + code: "import {stVars as XYZ} from './stylesheet.st.css'; const a = XYZ.key", }, ], }); diff --git a/packages/eslint-plugin-stylable/test/stylesheet.st.css b/packages/eslint-plugin-stylable/test/stylesheet.st.css new file mode 100644 index 000000000..e0fc3454c --- /dev/null +++ b/packages/eslint-plugin-stylable/test/stylesheet.st.css @@ -0,0 +1,9 @@ +:vars { + key: "value"; +} +.root { + --cssVar: green; + color: red; +} + +@keyframes test {} diff --git a/packages/language-service/src/lib-new/features/ls-css-pseudo-class.ts b/packages/language-service/src/lib-new/features/ls-css-pseudo-class.ts index 82613ab86..937bef800 100644 --- a/packages/language-service/src/lib-new/features/ls-css-pseudo-class.ts +++ b/packages/language-service/src/lib-new/features/ls-css-pseudo-class.ts @@ -66,7 +66,6 @@ export function getCompletions(context: LangServiceContext): Completion[] { completions.push( stateEnumCompletion( option, - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion normalizeDefinitionSheetLocation(context.meta, inStateParenDef!.meta), range(pos, { deltaStart: -startDelta }), ), diff --git a/packages/language-service/src/lib/provider.ts b/packages/language-service/src/lib/provider.ts index f412a2dc2..e34b4a874 100644 --- a/packages/language-service/src/lib/provider.ts +++ b/packages/language-service/src/lib/provider.ts @@ -295,8 +295,7 @@ export class Provider { ) { if (temp) { /* This is here because typescript does not recognize size effects during the if statement */ - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - const name = (temp as any).name; + const name = (temp as { name: string }).name; defs.push( new ProviderLocation( meta.source, diff --git a/packages/language-service/src/lib/utils/typescript-internals.d.ts b/packages/language-service/src/lib/utils/typescript-internals.d.ts index d1dd33d62..b1451c823 100644 --- a/packages/language-service/src/lib/utils/typescript-internals.d.ts +++ b/packages/language-service/src/lib/utils/typescript-internals.d.ts @@ -1,7 +1,6 @@ import ts from 'typescript'; declare module 'typescript' { - // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface NamedTupleMember {} // needed for custom readDirectory diff --git a/pleb.config.mjs b/pleb.config.mjs index 5ce10c036..b824377a9 100644 --- a/pleb.config.mjs +++ b/pleb.config.mjs @@ -4,7 +4,6 @@ export default { { name: 'mime', reason: 'esm only' }, { name: '@types/mime', reason: 'v4 has built-in types, but is esm only' }, { name: 'chai', reason: 'esm only from v5' }, - { name: 'eslint', reason: 'plugins are not yet compatible with v9' }, { name: 'rimraf', reason: 'v6 drops node 18 support' }, ], };