diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 13d8c5b..0000000 --- a/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -.vscode-test-web -coverage -lib -dist -preview -node_modules diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 1916415..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,41 +0,0 @@ -module.exports = { - root: true, - env: { - browser: true, - node: true, - }, - extends: ['eslint:recommended', 'plugin:import/recommended', 'prettier'], - rules: { - 'import/order': ['error', { alphabetize: { order: 'asc' } }], - }, - settings: { - 'import/resolver': { typescript: { alwaysTryTypes: true } }, - }, - overrides: [ - { - files: ['**/*.ts'], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:@typescript-eslint/stylistic', - 'plugin:import/typescript', - 'prettier', - ], - rules: { - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - }, - parserOptions: { - project: true, - tsconfigRootDir: __dirname, - }, - }, - { - files: ['**/*.test.js', '**/*.test.ts'], - plugins: ['jest'], - extends: ['plugin:jest/recommended', 'plugin:jest/style'], - }, - ], -} diff --git a/CHANGELOG.md b/CHANGELOG.md index 94a0a91..6c500ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,8 @@ ### Changed -- Upgrade dependent packages to the latest version ([#474](https://github.com/marp-team/marp-vscode/pull/474)) +- Upgrade development Node.js and dependent packages to the latest version ([#474](https://github.com/marp-team/marp-vscode/pull/474)) +- Migrate ESLint config to flat config ([#475](https://github.com/marp-team/marp-vscode/pull/475)) ## v2.8.0 - 2023-10-28 diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..34be26a --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,86 @@ +import js from '@eslint/js' +import eslintConfigPrettier from 'eslint-config-prettier' +import eslintPluginImport from 'eslint-plugin-import' +import eslintPluginJest from 'eslint-plugin-jest' +import eslintPluginUnicorn from 'eslint-plugin-unicorn' +import globals from 'globals' +import tseslint from 'typescript-eslint' + +const tsFiles = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'] +const testFiles = [ + '**/*.test.ts', + '**/*.test.tsx', + '**/*.test.mts', + '**/*.test.cts', + 'jest.setup.js', +] + +const forFiles = (files, confs) => confs.map((conf) => ({ ...conf, files })) + +export default tseslint.config( + js.configs.recommended, + eslintPluginImport.flatConfigs.recommended, + { + plugins: { + unicorn: eslintPluginUnicorn, + }, + rules: { + 'unicorn/prefer-node-protocol': 'error', + }, + }, + ...forFiles(tsFiles, [ + ...tseslint.configs.recommended, + ...tseslint.configs.stylistic, + { + extends: [eslintPluginImport.flatConfigs.recommended], + }, + { + rules: { + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/consistent-type-assertions': [ + 'error', + { assertionStyle: 'as' }, + ], + }, + }, + ]), + ...forFiles(testFiles, [ + eslintPluginJest.configs['flat/recommended'], + eslintPluginJest.configs['flat/style'], + { languageOptions: { globals: { ...globals.jest } } }, + ]), + eslintConfigPrettier, + { + linterOptions: { + reportUnusedDisableDirectives: 'error', + }, + languageOptions: { + ecmaVersion: 'latest', + parserOptions: { + ecmaFeatures: { jsx: true }, + }, + globals: { + ...globals.node, + ...globals.browser, + }, + }, + rules: { + 'import/order': ['error', { alphabetize: { order: 'asc' } }], + }, + settings: { + 'import/resolver': { typescript: { alwaysTryTypes: true } }, + }, + }, + { + ignores: [ + '.vscode-test-web/**/*', + 'coverage/**/*', + 'dist/**/*', + 'lib/**/*', + 'node_modules/**/*', + 'preview/**/*', + ], + }, +) diff --git a/jest.setup.js b/jest.setup.js index 71340e4..f95eef2 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -1,4 +1,4 @@ -import { TextEncoder, TextDecoder } from 'util' +import { TextEncoder, TextDecoder } from 'node:util' // TextEncoder and TextDecoder are exposed to global in Node.js and the browser. // Jest VM for testing seems not to expose them to JSDOM. diff --git a/package-lock.json b/package-lock.json index d2d47a2..6ba86dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ }, "devDependencies": { "@babel/preset-env": "^7.26.0", + "@eslint/js": "^9.17.0", "@marp-team/marp-core": "^4.0.1", "@types/color-string": "^1.5.5", "@types/express": "^4.17.21", @@ -20,8 +21,6 @@ "@types/lodash.debounce": "^4.0.9", "@types/markdown-it": "^14.1.2", "@types/vscode": "~1.86.0", - "@typescript-eslint/eslint-plugin": "^8.18.2", - "@typescript-eslint/parser": "^8.18.2", "@vscode/test-web": "^0.0.65", "@vscode/vsce": "^3.2.1", "abort-controller": "^3.0.0", @@ -34,8 +33,10 @@ "eslint-import-resolver-typescript": "^3.7.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-jest": "^28.10.0", + "eslint-plugin-unicorn": "^56.0.1", "express": "^4.21.2", "fetch-ponyfill": "^7.1.0", + "globals": "^15.14.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "jest-junit": "^16.0.0", @@ -58,6 +59,7 @@ "tslib": "^2.8.1", "typed-emitter": "^2.1.0", "typescript": "^5.7.2", + "typescript-eslint": "^8.18.2", "unified": "^11.0.5", "unist-util-visit": "^5.0.0", "util": "^0.12.5", @@ -1115,6 +1117,16 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-classes/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/plugin-transform-computed-properties": { "version": "7.25.9", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.25.9.tgz", @@ -1959,6 +1971,16 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { "version": "7.26.3", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.3.tgz", @@ -4338,6 +4360,13 @@ "undici-types": "~6.20.0" } }, + "node_modules/@types/normalize-package-data": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz", + "integrity": "sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/qs": { "version": "6.9.17", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.17.tgz", @@ -6131,6 +6160,19 @@ "dev": true, "license": "MIT" }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -6394,6 +6436,19 @@ "dev": true, "license": "MIT" }, + "node_modules/clean-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz", + "integrity": "sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^1.0.5" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -8540,6 +8595,91 @@ } } }, + "node_modules/eslint-plugin-unicorn": { + "version": "56.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-56.0.1.tgz", + "integrity": "sha512-FwVV0Uwf8XPfVnKSGpMg7NtlZh0G0gBarCaFcMUOoqPxXryxdYxTRRv4kH6B9TFCVIrjRXG+emcxIk2ayZilog==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.24.7", + "@eslint-community/eslint-utils": "^4.4.0", + "ci-info": "^4.0.0", + "clean-regexp": "^1.0.0", + "core-js-compat": "^3.38.1", + "esquery": "^1.6.0", + "globals": "^15.9.0", + "indent-string": "^4.0.0", + "is-builtin-module": "^3.2.1", + "jsesc": "^3.0.2", + "pluralize": "^8.0.0", + "read-pkg-up": "^7.0.1", + "regexp-tree": "^0.1.27", + "regjsparser": "^0.10.0", + "semver": "^7.6.3", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=18.18" + }, + "funding": { + "url": "https://github.com/sindresorhus/eslint-plugin-unicorn?sponsor=1" + }, + "peerDependencies": { + "eslint": ">=8.56.0" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/ci-info": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.1.0.tgz", + "integrity": "sha512-HutrvTNsF48wnxkzERIXOe5/mlcfFcbfCmwcg6CJnizbSue78AbDt+1cgl26zwn61WFxhcPykPfZrbqjGmBb4A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/regjsparser": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.10.0.tgz", + "integrity": "sha512-qx+xQGZVsy55CH0a1hiVwHmqjLryfh7wQyF5HO07XJ9f7dQMY/gPQHhlyDkIzJKC+x2fUCpCcUODUUUFrm7SHA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "jsesc": "~0.5.0" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/regjsparser/node_modules/jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + } + }, + "node_modules/eslint-plugin-unicorn/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/eslint-scope": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", @@ -9605,13 +9745,16 @@ } }, "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "15.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.14.0.tgz", + "integrity": "sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==", "dev": true, "license": "MIT", "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globalthis": { @@ -10171,6 +10314,16 @@ "node": ">=0.8.19" } }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -10335,6 +10488,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "license": "MIT", + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-bun-module": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.3.0.tgz", @@ -14472,6 +14641,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/minimatch": { "version": "9.0.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", @@ -14756,6 +14935,36 @@ "dev": true, "license": "MIT" }, + "node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "node_modules/normalize-package-data/node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true, + "license": "ISC" + }, + "node_modules/normalize-package-data/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -15553,6 +15762,16 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/portfinder": { "version": "1.0.32", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", @@ -16227,6 +16446,116 @@ "node": "^18.17.0 || >=20.5.0" } }, + "node_modules/read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg-up": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", + "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^4.1.0", + "read-pkg": "^5.2.0", + "type-fest": "^0.8.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-pkg-up/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg-up/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg-up/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-pkg-up/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg-up/node_modules/type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=8" + } + }, + "node_modules/read-pkg/node_modules/type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=8" + } + }, "node_modules/readable-stream": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", @@ -16336,6 +16665,16 @@ "@babel/runtime": "^7.8.4" } }, + "node_modules/regexp-tree": { + "version": "0.1.27", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", + "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", + "dev": true, + "license": "MIT", + "bin": { + "regexp-tree": "bin/regexp-tree" + } + }, "node_modules/regexp.prototype.flags": { "version": "1.5.3", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.3.tgz", @@ -17369,6 +17708,42 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/spdx-correct": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", + "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", + "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", + "dev": true, + "license": "CC-BY-3.0" + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.20", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.20.tgz", + "integrity": "sha512-jg25NiDV/1fLtSgEgyvVyDunvaNHbuwF9lfNV17gSmPFAlYzdfNBlLtLzXTevwkPj7DhGbmN9VnmJIgLnhvaBw==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/speech-rule-engine": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/speech-rule-engine/-/speech-rule-engine-4.0.7.tgz", @@ -17707,6 +18082,19 @@ "node": ">=6" } }, + "node_modules/strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -18802,6 +19190,29 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.18.2.tgz", + "integrity": "sha512-KuXezG6jHkvC3MvizeXgupZzaG5wjhU3yE8E7e6viOvAvD9xAWYp8/vy0WULTGe9DYDWcQu7aW03YIV3mSitrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.18.2", + "@typescript-eslint/parser": "8.18.2", + "@typescript-eslint/utils": "8.18.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.8.0" + } + }, "node_modules/uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", @@ -19133,6 +19544,17 @@ "node": ">=10.12.0" } }, + "node_modules/validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/package.json b/package.json index 25e2496..e08a889 100644 --- a/package.json +++ b/package.json @@ -259,7 +259,7 @@ "format": "prettier \"**/*.{css,js,json,md,scss,ts,yaml,yml}\"", "format:write": "npm run -s format -- --write", "lint:css": "stylelint \"./*.{css,scss}\"", - "lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint --ext .js,.ts --report-unused-disable-directives --cache .", + "lint:js": "eslint --cache", "package": "vsce package", "preversion": "run-p check:* lint:* test:*:coverage", "test:unit": "jest", @@ -273,6 +273,7 @@ }, "devDependencies": { "@babel/preset-env": "^7.26.0", + "@eslint/js": "^9.17.0", "@marp-team/marp-core": "^4.0.1", "@types/color-string": "^1.5.5", "@types/express": "^4.17.21", @@ -280,8 +281,6 @@ "@types/lodash.debounce": "^4.0.9", "@types/markdown-it": "^14.1.2", "@types/vscode": "~1.86.0", - "@typescript-eslint/eslint-plugin": "^8.18.2", - "@typescript-eslint/parser": "^8.18.2", "@vscode/test-web": "^0.0.65", "@vscode/vsce": "^3.2.1", "abort-controller": "^3.0.0", @@ -294,8 +293,10 @@ "eslint-import-resolver-typescript": "^3.7.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-jest": "^28.10.0", + "eslint-plugin-unicorn": "^56.0.1", "express": "^4.21.2", "fetch-ponyfill": "^7.1.0", + "globals": "^15.14.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "jest-junit": "^16.0.0", @@ -318,6 +319,7 @@ "tslib": "^2.8.1", "typed-emitter": "^2.1.0", "typescript": "^5.7.2", + "typescript-eslint": "^8.18.2", "unified": "^11.0.5", "unist-util-visit": "^5.0.0", "util": "^0.12.5", diff --git a/src/commands/export.ts b/src/commands/export.ts index 8f5f759..71c6ab4 100644 --- a/src/commands/export.ts +++ b/src/commands/export.ts @@ -1,5 +1,5 @@ -import { tmpdir } from 'os' -import path from 'path' +import { tmpdir } from 'node:os' +import path from 'node:path' import { nanoid } from 'nanoid' import { commands, diff --git a/src/directives/parser.ts b/src/directives/parser.ts index 494b37e..d2afdcc 100644 --- a/src/directives/parser.ts +++ b/src/directives/parser.ts @@ -1,11 +1,11 @@ -import { EventEmitter } from 'events' +import { EventEmitter } from 'node:events' import type { Root as RehypeRoot } from 'hast' import rehypeParse from 'rehype-parse' import remarkMath from 'remark-math' import remarkParse from 'remark-parse' import type { Root as RemarkRoot } from 'remark-parse/lib' import TypedEmitter from 'typed-emitter' -import { Processor, unified } from 'unified' +import { type Processor, unified } from 'unified' import { visit } from 'unist-util-visit' import { Range, TextDocument } from 'vscode' import yaml, { Pair, Scalar, YAMLMap } from 'yaml' diff --git a/src/extension.test.ts b/src/extension.test.ts index 30ab62f..675e23b 100644 --- a/src/extension.test.ts +++ b/src/extension.test.ts @@ -1,6 +1,6 @@ /** @jest-environment jsdom */ -import path from 'path' -import { TextEncoder } from 'util' +import path from 'node:path' +import { TextEncoder } from 'node:util' import { Marp } from '@marp-team/marp-core' import dedent from 'dedent' import markdownIt from 'markdown-it' diff --git a/src/language/parser.test.ts b/src/language/parser.test.ts index c32e47a..05c893b 100644 --- a/src/language/parser.test.ts +++ b/src/language/parser.test.ts @@ -1,4 +1,4 @@ -import { nextTick } from 'process' +import { nextTick } from 'node:process' import dedent from 'dedent' import { Disposable, diff --git a/src/language/parser.ts b/src/language/parser.ts index 29ab192..c230bdd 100644 --- a/src/language/parser.ts +++ b/src/language/parser.ts @@ -1,4 +1,4 @@ -import { EventEmitter } from 'events' +import { EventEmitter } from 'node:events' import lodashDebounce from 'lodash.debounce' import type TypedEmitter from 'typed-emitter' import { diff --git a/src/marp-cli.test.ts b/src/marp-cli.test.ts index 47f97b6..80e0adc 100644 --- a/src/marp-cli.test.ts +++ b/src/marp-cli.test.ts @@ -1,5 +1,5 @@ -import { tmpdir } from 'os' -import path from 'path' +import { tmpdir } from 'node:os' +import path from 'node:path' import * as marpCliModule from '@marp-team/marp-cli' import { workspace } from 'vscode' import * as marpCli from './marp-cli' diff --git a/src/marp-cli.ts b/src/marp-cli.ts index 20c0073..43cc4ab 100644 --- a/src/marp-cli.ts +++ b/src/marp-cli.ts @@ -1,5 +1,5 @@ -import { tmpdir } from 'os' -import path from 'path' +import { tmpdir } from 'node:os' +import path from 'node:path' import type { marpCli } from '@marp-team/marp-cli' import { nanoid } from 'nanoid' import { TextDocument, Uri, workspace } from 'vscode' diff --git a/src/option.ts b/src/option.ts index 2bb8d2a..4c34c04 100644 --- a/src/option.ts +++ b/src/option.ts @@ -1,5 +1,5 @@ -import { tmpdir } from 'os' -import path from 'path' +import { tmpdir } from 'node:os' +import path from 'node:path' import { MarpOptions } from '@marp-team/marp-core' import { Options } from 'markdown-it' import { nanoid } from 'nanoid' diff --git a/src/workspace-proxy-server.ts b/src/workspace-proxy-server.ts index f5be1ff..0b7c454 100644 --- a/src/workspace-proxy-server.ts +++ b/src/workspace-proxy-server.ts @@ -1,5 +1,5 @@ -import type { Server } from 'http' -import path from 'path' +import type { Server } from 'node:http' +import path from 'node:path' import express from 'express' import { getPortPromise } from 'portfinder' import { FileType, Uri, workspace, WorkspaceFolder } from 'vscode' diff --git a/webpack.base.config.js b/webpack.base.config.js index 8109400..df69873 100644 --- a/webpack.base.config.js +++ b/webpack.base.config.js @@ -1,6 +1,7 @@ -const path = require('path') +const path = require('node:path') const esbuild = require('esbuild') const { EsbuildPlugin } = require('esbuild-loader') +const { NormalModuleReplacementPlugin } = require('webpack') module.exports = ({ outputPath, production, minimizerFormat }) => ({ mode: production ? 'production' : 'none', @@ -38,7 +39,12 @@ module.exports = ({ outputPath, production, minimizerFormat }) => ({ }), ], }, - plugins: [], + plugins: [ + // Remove 'node:' prefix + new NormalModuleReplacementPlugin(/^node:/, (resource) => { + resource.request = resource.request.replace(/^node:/, '') + }), + ], performance: { hints: false, }, diff --git a/webpack.config.js b/webpack.config.js index d1c01c1..79c858c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,4 @@ -const assert = require('assert') +const assert = require('node:assert') const configurations = { node: require('./webpack.node.config'), diff --git a/webpack.node.config.js b/webpack.node.config.js index 37db98a..ac87200 100644 --- a/webpack.node.config.js +++ b/webpack.node.config.js @@ -1,4 +1,4 @@ -const path = require('path') +const path = require('node:path') const pkg = require('./package.json') const base = require('./webpack.base.config') diff --git a/webpack.preview.config.js b/webpack.preview.config.js index c0aa093..9357b25 100644 --- a/webpack.preview.config.js +++ b/webpack.preview.config.js @@ -1,4 +1,4 @@ -const path = require('path') +const path = require('node:path') const base = require('./webpack.base.config') const outputPath = path.resolve(__dirname, './preview/preview.js') diff --git a/webpack.web.config.js b/webpack.web.config.js index 63213ff..22a6e25 100644 --- a/webpack.web.config.js +++ b/webpack.web.config.js @@ -1,4 +1,4 @@ -const path = require('path') +const path = require('node:path') const { ProvidePlugin } = require('webpack') const pkg = require('./package.json') const base = require('./webpack.base.config')