From 71a67d6c925fee7e581fb0c6eaaa33fecef09b5d Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Mon, 23 Sep 2024 13:40:56 +0200 Subject: [PATCH 1/7] chore(common): upgrade eslint --- .eslintignore | 6 - .eslintrc.cjs | 132 - .github/workflows/ci-library.yml | 1 - eslint.config.js | 58 + package.json | 16 +- packages/cli/src/__tests__/utils.test.ts | 4 - .../cli/src/commands/__tests__/deploy.test.ts | 13 +- packages/cli/src/commands/add.ts | 2 - .../commands/create/__tests__/index.test.ts | 1 - packages/cli/src/commands/create/monorepo.ts | 2 - packages/cli/src/commands/deploy/helper.ts | 3 +- packages/cli/src/main.ts | 1 - .../cli/src/storyblok/storyblok-client.ts | 3 - packages/cli/src/utils.ts | 11 +- packages/cli/templates/js/.eslintrc.cjs | 12 - packages/cli/templates/js/package.json | 2 - packages/cli/templates/react/.eslintrc.cjs | 34 - packages/cli/templates/react/eslint.config.js | 40 + packages/cli/templates/react/package.json | 13 +- packages/cli/templates/react/src/App.tsx | 2 +- .../templates/react/src/createRootElement.ts | 1 - packages/cli/templates/react/src/main.tsx | 1 - packages/cli/templates/react/vite.config.ts | 2 +- packages/cli/templates/vue2/src/App.vue | 4 +- .../FieldPluginExample/AssetSelector.vue | 18 +- .../FieldPluginExample/ModalToggle.vue | 6 +- .../components/FieldPluginExample/index.vue | 36 +- .../cli/templates/vue2/src/fieldPlugin.js | 1 - packages/cli/templates/vue3/src/App.vue | 2 +- .../FieldPluginExample/AssetSelector.vue | 2 +- .../components/FieldPluginExample/index.vue | 8 +- packages/demo/.eslintrc.cjs | 15 - packages/demo/package.json | 4 - packages/demo/src/components/App.tsx | 2 +- .../demo/src/components/HeightChangeDemo.tsx | 2 +- packages/demo/src/createRootElement.ts | 1 - packages/demo/src/main.tsx | 1 - .../field-plugin/helpers/react/.eslintrc.cjs | 15 - .../field-plugin/helpers/react/package.json | 8 - .../field-plugin/helpers/test/src/index.ts | 28 +- .../field-plugin/helpers/vue3/.eslintrc.json | 20 - .../field-plugin/helpers/vue3/package.json | 7 - .../createFieldPlugin/createFieldPlugin.ts | 2 - .../createHeightChangeListener.test.ts | 3 - .../createPluginActions/callbackQueue.ts | 5 +- .../createPluginActions.test.ts | 4 +- .../createPluginActions.ts | 1 - .../recordFromFieldPluginOptions.ts | 1 - .../PluginLoadedMessage.test.ts | 2 +- .../ValueChangeMessage.test.ts | 2 +- packages/sandbox/.eslintrc.cjs | 15 - packages/sandbox/package.json | 4 - .../src/components/FieldPluginSandbox.tsx | 4 +- .../src/components/ObjectView/ObjectView.tsx | 2 +- scripts/bump-version.ts | 4 - scripts/prepare-dev-vite-configs.mjs | 31 +- yarn.lock | 4326 +++++++++-------- 57 files changed, 2403 insertions(+), 2543 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.cjs create mode 100644 eslint.config.js delete mode 100644 packages/cli/templates/js/.eslintrc.cjs delete mode 100644 packages/cli/templates/react/.eslintrc.cjs create mode 100644 packages/cli/templates/react/eslint.config.js delete mode 100644 packages/demo/.eslintrc.cjs delete mode 100644 packages/field-plugin/helpers/react/.eslintrc.cjs delete mode 100644 packages/field-plugin/helpers/vue3/.eslintrc.json delete mode 100644 packages/sandbox/.eslintrc.cjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index e315547e..00000000 --- a/.eslintignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules/ -packages/*/node_modules/ -packages/*/dist/ -packages/cli/templates/ -packages/field-plugin/helpers/ -build.config.ts \ No newline at end of file diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 2c77d2ef..00000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,132 +0,0 @@ -const numberFromStringMessage = (forbiddenToken) => - `"Usage of ${forbiddenToken} is forbidden. Create one utility function "numberFromString()" that 1) parses a number from a string with Number(), 2) adds an exception to the eslint rule, 3) checks for NaN with Number.isNaN(), 4) checks for infinities with Number.isFinite(), 4) return the parsed number or undefined if the checks failed.` - -module.exports = { - root: true, - extends: ['prettier', 'eslint:recommended'], - plugins: ['prettier', 'functional'], - parser: '@typescript-eslint/parser', - overrides: [ - // For parsing ts files with type information - { - files: ['*.ts', '*.tsx'], // Your TypeScript files extension - - // As mentioned in the comments, you should extend TypeScript plugins here, - // instead of extending them outside the `overrides`. - // If you don't want to extend any rules, you don't need an `extends` attribute. - extends: [ - 'plugin:@typescript-eslint/recommended', - 'plugin:@typescript-eslint/recommended-requiring-type-checking', - ], - parserOptions: { - tsconfigRootDir: __dirname, - project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'], - }, - plugins: ['@typescript-eslint'], - rules: { - '@typescript-eslint/restrict-plus-operands': 'error', - '@typescript-eslint/strict-boolean-expressions': [ - 'error', - { - allowNullableObject: true, - allowNullableBoolean: true, - } - ], - '@typescript-eslint/no-misused-promises': 'off', - '@typescript-eslint/no-explicit-any': 'error', - '@typescript-eslint/no-unused-vars': [ - 'warn', - { - args: 'none', - argsIgnorePattern: '^_', - varsIgnorePattern: '^_', - caughtErrorsIgnorePattern: '^_', - }, - ], - }, - }, - { - files: ['*.test.ts', '*.test.tsx'], - env: { - jest: true, - node: true, - }, - }, - { - files: ['packages/cli/**'], - rules: { - 'no-console': 'off', - }, - }, - ], - rules: { - 'no-warning-comments': 'warn', - 'use-isnan': 'error', - eqeqeq: 'error', - 'no-var': 'error', - 'no-bitwise': 'error', - 'no-console': [ - 'warn', - { - allow: ['warn', 'error'], - }, - ], - 'no-inline-comments': 'warn', - 'no-param-reassign': 'error', - 'no-implicit-coercion': 'error', - 'functional/immutable-data': 'error', - 'functional/no-let': 'error', - 'functional/no-throw-statement': 'error', - 'functional/no-class': 'error', - 'functional/no-this-expression': 'error', - 'functional/no-loop-statement': 'error', - 'functional/no-promise-reject': 'error', - 'no-unused-vars': [ - 'off', - { - argsIgnorePattern: '^_', - varsIgnorePattern: '^_', - caughtErrorsIgnorePattern: '^_', - }, - ], - 'prettier/prettier': ['warn'], - yoda: 'warn', - 'no-restricted-properties': [ - 'error', - { - object: 'Number', - property: 'parseInt', - message: numberFromStringMessage('Number.parseInt()'), - }, - { - object: 'Number', - property: 'parseFloat', - message: numberFromStringMessage('Number.parseFloat()'), - }, - ], - 'no-restricted-syntax': [ - 'error', - { - selector: "CallExpression[callee.name='parseInt']", - message: numberFromStringMessage('parseInt()'), - }, - { - selector: "CallExpression[callee.name='parseFloat']", - message: numberFromStringMessage('parseFloat()'), - }, - { - selector: "CallExpression[callee.name='Number']", - message: numberFromStringMessage('Number()'), - }, - // Function expressions are useful in a few contexts of higher order components when the function needs to be named. - // { - // "selector": "FunctionExpression", - // "message": "Prefer arrow functions over function expressions." - // }, - { - selector: 'FunctionDeclaration', - message: 'Prefer arrow functions over function declarations.', - }, - ], - }, -} diff --git a/.github/workflows/ci-library.yml b/.github/workflows/ci-library.yml index 5fb5331d..a0612eee 100644 --- a/.github/workflows/ci-library.yml +++ b/.github/workflows/ci-library.yml @@ -21,7 +21,6 @@ jobs: - name: Lint run: | yarn eslint packages/field-plugin - yarn workspaces foreach --include "helper-*" run lint - name: Test run: | yarn workspace @storyblok/field-plugin test diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..eac1b957 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,58 @@ +import globals from 'globals' +import eslintJs from '@eslint/js' +import tsEslint from 'typescript-eslint' +import prettier from 'eslint-config-prettier' +import react from 'eslint-plugin-react' +import vue from 'eslint-plugin-vue' +import vueParser from 'vue-eslint-parser' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' + +export default [ + { + ignores: ['**/node_modules/', '**/dist/'], + }, + { files: ['**/*.{js,mjs,cjs,ts}'] }, + { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, + prettier, + eslintJs.configs.recommended, + ...tsEslint.configs.recommended, + + ...vue.configs['flat/recommended'], + { + files: ['**/*.vue'], + languageOptions: { + parser: vueParser, + parserOptions: { + parser: tsEslint.parser, + }, + }, + }, + + react.configs.flat.recommended, + react.configs.flat['jsx-runtime'], + { + plugins: { + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + }, + { + rules: { + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'all', + argsIgnorePattern: '^_', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], + 'react/prop-types': 'off', + 'vue/multi-word-component-names': 'off', + }, + }, +] diff --git a/package.json b/package.json index 89188c43..a9bb5f97 100644 --- a/package.json +++ b/package.json @@ -60,22 +60,26 @@ "bump-version": "./scripts/bump-version.ts" }, "devDependencies": { + "@eslint/js": "9.11.0", "@storyblok/mui": "0.2.0", "@types/node": "18.19.17", - "@typescript-eslint/eslint-plugin": "^5.30.7", - "@typescript-eslint/parser": "^5.30.7", - "eslint": "8.56.0", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-functional": "^4.2.2", - "eslint-plugin-prettier": "^5.1.3", + "eslint": "9.11.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-react": "7.36.1", + "eslint-plugin-react-hooks": "4.6.2", + "eslint-plugin-react-refresh": "0.4.12", + "eslint-plugin-vue": "9.28.0", + "globals": "15.9.0", "kleur": "4.1.5", "prettier": "^3.2.5", "prompts": "2.4.2", "semver": "7.6.0", "tsx": "3.14.0", "typescript": "^5.3.3", + "typescript-eslint": "8.6.0", "vite": "5.1.3", "vite-plugin-dts": "1.7.3", + "vue-eslint-parser": "9.4.3", "zx": "7.2.3" } } diff --git a/packages/cli/src/__tests__/utils.test.ts b/packages/cli/src/__tests__/utils.test.ts index b61c9c35..31b40751 100644 --- a/packages/cli/src/__tests__/utils.test.ts +++ b/packages/cli/src/__tests__/utils.test.ts @@ -57,7 +57,6 @@ describe('utils', () => { describe('dotEnvPath is given', () => { it('returns error if env file does not have token', async () => { vi.mocked(existsSync).mockImplementation(() => true) - // eslint-disable-next-line functional/immutable-data delete process.env.STORYBLOK_PERSONAL_ACCESS_TOKEN const result = await getPersonalAccessToken({ token: undefined, @@ -74,7 +73,6 @@ describe('utils', () => { it('returns token if env file has token', async () => { vi.mocked(existsSync).mockImplementation(() => true) - // eslint-disable-next-line functional/immutable-data process.env.STORYBLOK_PERSONAL_ACCESS_TOKEN = 'my-token' const result = await getPersonalAccessToken({ token: undefined, @@ -90,7 +88,6 @@ describe('utils', () => { describe('dotEnvPath is not given', () => { it('returns error if env files do not have token', async () => { vi.mocked(existsSync).mockImplementation(() => true) - // eslint-disable-next-line functional/immutable-data delete process.env.STORYBLOK_PERSONAL_ACCESS_TOKEN const result = await getPersonalAccessToken({ token: undefined, @@ -108,7 +105,6 @@ describe('utils', () => { it('returns token if env files have token', async () => { vi.mocked(existsSync).mockImplementation(() => true) - // eslint-disable-next-line functional/immutable-data process.env.STORYBLOK_PERSONAL_ACCESS_TOKEN = 'my-token' const result = await getPersonalAccessToken({ token: undefined, diff --git a/packages/cli/src/commands/__tests__/deploy.test.ts b/packages/cli/src/commands/__tests__/deploy.test.ts index 3cb787dd..42bef4b4 100644 --- a/packages/cli/src/commands/__tests__/deploy.test.ts +++ b/packages/cli/src/commands/__tests__/deploy.test.ts @@ -15,7 +15,6 @@ vi.mock('fs') describe('deploy', () => { const exit = vi.fn(() => { - // eslint-disable-next-line functional/no-throw-statement throw new Error('Exiting Process Error') }) @@ -128,11 +127,11 @@ const defaultDeployArgs: DeployArgs = { } const mockPersonalAccessTokenSuccess = () => - vi.mocked(getPersonalAccessToken).mockImplementation((params) => { + vi.mocked(getPersonalAccessToken).mockImplementation(() => { return Promise.resolve({ error: false, token: 'token' }) }) const mockPersonalAccessTokenError = () => - vi.mocked(getPersonalAccessToken).mockImplementation((params) => { + vi.mocked(getPersonalAccessToken).mockImplementation(() => { return Promise.resolve({ error: true, message: 'getPersonalAccessToken Error', @@ -140,20 +139,20 @@ const mockPersonalAccessTokenError = () => }) const mockPackageJsonNameError = () => - vi.mocked(getPackageName).mockImplementation((name) => { + vi.mocked(getPackageName).mockImplementation(() => { return Promise.resolve({ error: true }) }) const mockPackageJsonNameSuccess = () => - vi.mocked(getPackageName).mockImplementation((name) => { + vi.mocked(getPackageName).mockImplementation(() => { return Promise.resolve({ error: false, name: 'test name' }) }) const mockPackageJsonNameSuccessEmpty = () => - vi.mocked(upsertFieldPlugin).mockImplementation((name) => { + vi.mocked(upsertFieldPlugin).mockImplementation(() => { return Promise.resolve({ id: 1 }) }) const mockUpsertFieldPluginSuccess = () => - vi.mocked(upsertFieldPlugin).mockImplementation((name) => { + vi.mocked(upsertFieldPlugin).mockImplementation(() => { return Promise.resolve({ id: 1 }) }) diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts index 7850817e..42725d78 100644 --- a/packages/cli/src/commands/add.ts +++ b/packages/cli/src/commands/add.ts @@ -91,11 +91,9 @@ export const add: AddFunc = async (args) => { readFileSync(file).toString(), ) as PackageJson - // eslint-disable-next-line functional/immutable-data packageJson['name'] = packageName if (args.structure === 'monorepo') { - // eslint-disable-next-line functional/immutable-data, @typescript-eslint/no-unsafe-member-access packageJson['scripts']['deploy'] += " --dotEnvPath '../../.env'" } diff --git a/packages/cli/src/commands/create/__tests__/index.test.ts b/packages/cli/src/commands/create/__tests__/index.test.ts index 9bd14dac..fb614c5e 100644 --- a/packages/cli/src/commands/create/__tests__/index.test.ts +++ b/packages/cli/src/commands/create/__tests__/index.test.ts @@ -12,7 +12,6 @@ vi.mock('../monorepo') vi.mock('../standalone') describe('create', () => { - // eslint-disable-next-line functional/no-let let utils: typeof import('../../../utils') beforeAll(async () => { diff --git a/packages/cli/src/commands/create/monorepo.ts b/packages/cli/src/commands/create/monorepo.ts index ecc0d631..403e62c2 100644 --- a/packages/cli/src/commands/create/monorepo.ts +++ b/packages/cli/src/commands/create/monorepo.ts @@ -58,9 +58,7 @@ const specifyPackageManager = ({ readFileSync(resolve(repoDir, 'package.json')).toString(), ) as Record & { scripts: Record } - // eslint-disable-next-line functional/immutable-data json['scripts']['add-plugin'] += ` --packageManager ${packageManager}` - // eslint-disable-next-line functional/immutable-data json['packageManager'] = packageManager === 'yarn' ? 'yarn@3.2.4' : 'pnpm@8.14.0' diff --git a/packages/cli/src/commands/deploy/helper.ts b/packages/cli/src/commands/deploy/helper.ts index 2f000033..5936b0b3 100644 --- a/packages/cli/src/commands/deploy/helper.ts +++ b/packages/cli/src/commands/deploy/helper.ts @@ -148,7 +148,7 @@ export const getPackageJsonName = (path: string): string | undefined => { return } - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + const json: { name: string } = JSON.parse( readFileSync(resolve(path, 'package.json')).toString(), ) @@ -394,7 +394,6 @@ export const createFieldPlugin = async ( return fieldPlugin } catch (err) { if (skipPrompts || getErrorMessage(err) !== 'DUPLICATED_NAME') { - // eslint-disable-next-line functional/no-throw-statement throw err } diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts index 5de50e67..345e9e82 100644 --- a/packages/cli/src/main.ts +++ b/packages/cli/src/main.ts @@ -1,4 +1,3 @@ -/* eslint-disable functional/no-this-expression */ import { create, add, diff --git a/packages/cli/src/storyblok/storyblok-client.ts b/packages/cli/src/storyblok/storyblok-client.ts index c66b26da..4f6e02b0 100644 --- a/packages/cli/src/storyblok/storyblok-client.ts +++ b/packages/cli/src/storyblok/storyblok-client.ts @@ -77,13 +77,11 @@ export const StoryblokClient: StoryblokClientFunc = ({ token, scope }) => { const fetchAllFieldTypes = async () => { const results: FieldType[] = [] - // eslint-disable-next-line functional/no-loop-statement, functional/no-let for (let page = 1; page <= 100; page++) { const fieldTypes = await fetchFieldTypes(page) if (fieldTypes.length === 0) { break } - // eslint-disable-next-line functional/immutable-data results.push(...fieldTypes) } return results @@ -140,7 +138,6 @@ const handleErrorIfExists = ( } if (isDuplicatedNameError(json)) { - // eslint-disable-next-line functional/no-throw-statement throw new Error('DUPLICATED_NAME') } diff --git a/packages/cli/src/utils.ts b/packages/cli/src/utils.ts index f6c81eb8..817a0563 100644 --- a/packages/cli/src/utils.ts +++ b/packages/cli/src/utils.ts @@ -32,7 +32,7 @@ export const runCommand: RunCommandFunc = async ( if (spinner) { spinner.fail() } - // eslint-disable-next-line + throw err } } @@ -123,7 +123,7 @@ export const promptName = async ({ } export const filterPathsToInclude = ( - directory: string, + _directory: string, files: string[], ): string[] | Promise => files.filter( @@ -146,7 +146,7 @@ export const initializeNewRepo = async ({ dir }: { dir: string }) => { shell: true, cwd: dir, }) - } catch (err) { + } catch (_err) { // ignore if git commands fail } } @@ -155,7 +155,7 @@ export const checkIfInsideRepository = async ({ dir }: { dir: string }) => { try { await runCommand('git rev-parse --is-inside-work-tree', { cwd: dir }) return true - } catch (err) { + } catch (_err) { return false } } @@ -275,13 +275,10 @@ export const selectTemplate = async () => { } export const randomString = (length = 16) => { - // eslint-disable-next-line functional/no-let let result = '' const characters = 'abcdefghijklmnopqrstuvwxyz0123456789-' const charactersLength = characters.length - // eslint-disable-next-line functional/no-let let counter = 0 - // eslint-disable-next-line functional/no-loop-statement while (counter < length) { result += characters.charAt(Math.floor(Math.random() * charactersLength)) counter += 1 diff --git a/packages/cli/templates/js/.eslintrc.cjs b/packages/cli/templates/js/.eslintrc.cjs deleted file mode 100644 index ae93ad8e..00000000 --- a/packages/cli/templates/js/.eslintrc.cjs +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - root: true, - env: { - browser: true, - es6: true, - }, - extends: ["eslint:recommended"], - parserOptions: { - ecmaVersion: 'latest', - sourceType: "module", - }, -} \ No newline at end of file diff --git a/packages/cli/templates/js/package.json b/packages/cli/templates/js/package.json index 29645bca..e4062fb5 100644 --- a/packages/cli/templates/js/package.json +++ b/packages/cli/templates/js/package.json @@ -6,7 +6,6 @@ "scripts": { "dev": "vite", "build": "vite build", - "lint": "eslint .", "check:types": "tsc --noEmit", "deploy": "npm run build && npx @storyblok/field-plugin-cli@latest deploy" }, @@ -14,7 +13,6 @@ "@storyblok/field-plugin": "1.2.1" }, "devDependencies": { - "eslint": "latest", "vite": "^5.1.3", "vite-plugin-css-injected-by-js": "2.4.0" } diff --git a/packages/cli/templates/react/.eslintrc.cjs b/packages/cli/templates/react/.eslintrc.cjs deleted file mode 100644 index 7016e2ad..00000000 --- a/packages/cli/templates/react/.eslintrc.cjs +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = { - root: true, - globals: { - React: true, - JSX: true, - }, - env: { - browser: true, - es2021: true, - }, - settings: { - react: { - version: 'detect', - }, - }, - extends: [ - 'eslint:recommended', - 'plugin:react/recommended', - 'plugin:@typescript-eslint/recommended', - ], - overrides: [], - parser: '@typescript-eslint/parser', - - parserOptions: { - tsconfigRootDir: __dirname, - ecmaVersion: 'latest', - sourceType: 'module', - project: ['./tsconfig.json', './tsconfig.node.json'], - }, - plugins: ['react', '@typescript-eslint'], - rules: { - 'react/prop-types': 'off', - } -} diff --git a/packages/cli/templates/react/eslint.config.js b/packages/cli/templates/react/eslint.config.js new file mode 100644 index 00000000..d50208c9 --- /dev/null +++ b/packages/cli/templates/react/eslint.config.js @@ -0,0 +1,40 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' + +export default tseslint.config( + { ignores: ['dist'] }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['**/*.{ts,tsx}'], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'all', + argsIgnorePattern: '^_', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], + }, + }, +) diff --git a/packages/cli/templates/react/package.json b/packages/cli/templates/react/package.json index a92ca540..5b049d97 100644 --- a/packages/cli/templates/react/package.json +++ b/packages/cli/templates/react/package.json @@ -7,6 +7,7 @@ "dev": "vite", "test": "vitest", "build": "tsc && vite build", + "lint": "eslint .", "preview": "vite preview", "deploy": "npm run build && npx @storyblok/field-plugin-cli@latest deploy" }, @@ -16,21 +17,23 @@ "react-dom": "^18.2.0" }, "devDependencies": { + "@eslint/js": "^9.9.0", "@testing-library/jest-dom": "6.4.2", "@testing-library/react": "14.2.1", "@testing-library/user-event": "14.5.2", "@types/react": "^18.2.56", "@types/react-dom": "^18.2.19", - "@typescript-eslint/eslint-plugin": "6.1.0", - "@typescript-eslint/parser": "6.1.0", "@vitejs/plugin-react": "^4.1.0", "@vitest/ui": "1.3.0", - "eslint": "latest", - "eslint-plugin-react": "7.33.2", + "eslint": "^9.9.0", + "eslint-plugin-react-hooks": "^5.1.0-rc.0", + "eslint-plugin-react-refresh": "^0.4.9", + "globals": "^15.9.0", "jsdom": "22.1.0", "typescript": "5.3.3", + "typescript-eslint": "^8.0.1", "vite": "5.1.3", "vite-plugin-css-injected-by-js": "3.1.0", - "vitest": "1.3.0" + "vitest": "2.1.1" } } diff --git a/packages/cli/templates/react/src/App.tsx b/packages/cli/templates/react/src/App.tsx index 80ff9bfe..c55500ec 100644 --- a/packages/cli/templates/react/src/App.tsx +++ b/packages/cli/templates/react/src/App.tsx @@ -1,4 +1,4 @@ -import FieldPlugin from './components/FieldPlugin' +import _FieldPlugin from './components/FieldPlugin' import FieldPluginExample from './components/FieldPluginExample' import { FunctionComponent } from 'react' diff --git a/packages/cli/templates/react/src/createRootElement.ts b/packages/cli/templates/react/src/createRootElement.ts index 2a3fcf4f..aeab28d1 100644 --- a/packages/cli/templates/react/src/createRootElement.ts +++ b/packages/cli/templates/react/src/createRootElement.ts @@ -1,6 +1,5 @@ export const createRootElement = (id?: string): HTMLElement => { // In production, `#app` may or may not exist. - /* eslint-disable functional/immutable-data */ const rootElement = document.createElement('div') rootElement.id = id ?? 'app' return rootElement diff --git a/packages/cli/templates/react/src/main.tsx b/packages/cli/templates/react/src/main.tsx index 5f4559f3..92935c24 100644 --- a/packages/cli/templates/react/src/main.tsx +++ b/packages/cli/templates/react/src/main.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { createRoot } from 'react-dom/client' import App from './App' import './style.css' diff --git a/packages/cli/templates/react/vite.config.ts b/packages/cli/templates/react/vite.config.ts index b24f1215..7887f588 100644 --- a/packages/cli/templates/react/vite.config.ts +++ b/packages/cli/templates/react/vite.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ environment: 'jsdom', setupFiles: ['./src/setupTests.ts'], }, - // @ts-ignore + // @ts-expect-error unknown type error plugins: [react(), cssInjectedByJs(), ...plugins], build: { rollupOptions: { diff --git a/packages/cli/templates/vue2/src/App.vue b/packages/cli/templates/vue2/src/App.vue index cb48ee01..65b63176 100644 --- a/packages/cli/templates/vue2/src/App.vue +++ b/packages/cli/templates/vue2/src/App.vue @@ -3,12 +3,12 @@ diff --git a/packages/cli/templates/vue3/src/components/FieldPluginExample/AssetSelector.vue b/packages/cli/templates/vue3/src/components/FieldPluginExample/AssetSelector.vue index 42ff8cc4..624261ef 100644 --- a/packages/cli/templates/vue3/src/components/FieldPluginExample/AssetSelector.vue +++ b/packages/cli/templates/vue3/src/components/FieldPluginExample/AssetSelector.vue @@ -22,7 +22,7 @@ const removeAsset = () => { v-if="asset" :src="asset.filename" title="Selected Asset" - /> + >