VSCode и Eslint не распознают новые файлы с CRA только после перезагрузки окна - PullRequest
0 голосов
/ 12 апреля 2020

Eslint (VSCode Extention) не работает с новыми файлами Typescript в приложении CRA. Мне всегда нужно перезагрузить окно. Тогда все работает нормально.

В этом случае проблема в Test.tsx

tsconig. json:

{
  "compilerOptions": {
    "target": "es2017",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ],
}

.eslint. js

module.exports = {
  env: {
    browser: true,
    es6: true,
  },
  extends: ['plugin:react/recommended', 'airbnb-typescript', 'plugin:prettier/recommended', 'prettier/react'],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: 'module',
    project: './tsconfig.json',
  },
  plugins: ['react', '@typescript-eslint'],
  rules: {
    'spaced-comment': ['error', 'always', { markers: ['/'] }],
  },
  overrides: [
    {
      files: ['*.test.tsx', '*.test.ts', 'setupTests.ts', './src/testUtils/*'],
      rules: {
        'import/no-extraneous-dependencies': 'off',
      },
    },
    {
      files: ['*.stories.tsx', '*.stories.ts'],
      rules: {
        'import/no-extraneous-dependencies': 'off',
      },
    },
  ],
};

deps в упаковке. json

  "dependencies": {
    "@material-ui/core": "^4.9.9",
    "css": "^2.2.4",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "styled-components": "^5.1.0",
    "typescript": "~3.7.2"
  },
  "devDependencies": {
    "@storybook/addon-actions": "^5.3.18",
    "@storybook/addon-docs": "^5.3.18",
    "@storybook/addon-knobs": "^5.3.18",
    "@storybook/addon-links": "^5.3.18",
    "@storybook/addons": "^5.3.18",
    "@storybook/preset-create-react-app": "^2.1.1",
    "@storybook/react": "^5.3.18",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/enzyme": "^3.10.5",
    "@types/enzyme-adapter-react-16": "^1.0.6",
    "@types/jest": "^24.0.0",
    "@types/react": "^16.9.0",
    "@types/react-dom": "^16.9.0",
    "@types/styled-components": "^5.0.1",
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.2",
    "eslint-config-airbnb-typescript": "^7.2.0",
    "eslint-config-prettier": "^6.10.1",
    "eslint-plugin-prettier": "^3.1.2",
    "prettier": "^2.0.4",
    "react-scripts": "3.4.1",
    "storybook-addon-styled-component-theme": "^1.3.0"
  },

Выход DEBUG=typescript-eslint:* yarn eslint src/**/*:

DEBUG=typescript-eslint:* yarn eslint src/**/*
yarn run v1.22.4
$ /home/dietmar/vsCodeProjects/smartHome.component-library/node_modules/.bin/eslint src/components/button.stories.tsx src/components/Button.tsx src/components/styled-button.stories.tsx src/components/styled-button.tsx src/components/Test.tsx src/docs/Introduction.stories.mdx src/testUtils/mountWithTheme.tsx src/testUtils/renderWithTheme.tsx src/testUtils/shallowWithTheme.tsx src/themes/darkTheme.ts src/themes/ITheme.ts src/themes/lightTheme.ts
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/button.stories.tsx +0ms
  typescript-eslint:typescript-estree:createWatchProgram File did not belong to any existing programs, moving to create/update. /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/button.stories.tsx +0ms
  typescript-eslint:typescript-estree:createWatchProgram Creating watch program for /home/dietmar/vsCodeProjects/smartHome.component-library/tsconfig.json. +0ms
  typescript-eslint:typescript-estree:createWatchProgram Running without timeout fix +1ms
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/Button.tsx +3s
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/Button.tsx +3s
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/styled-button.stories.tsx +67ms
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/styled-button.stories.tsx +66ms
  typescript-eslint:typescript-estree:createIsolatedProgram Getting isolated program in TSX mode for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/styled-button.tsx +0ms
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/styled-button.tsx +38ms
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/styled-button.tsx +38ms
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/Test.tsx +46ms
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/components/Test.tsx +46ms
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/testUtils/mountWithTheme.tsx +22ms
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/testUtils/mountWithTheme.tsx +22ms
  typescript-eslint:typescript-estree:createIsolatedProgram Getting isolated program in TS mode for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/themes/lightTheme.ts +114ms
  typescript-eslint:typescript-estree:createIsolatedProgram Getting isolated program in TS mode for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/themes/ITheme.ts +6ms
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/testUtils/renderWithTheme.tsx +55ms
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/testUtils/renderWithTheme.tsx +55ms
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/testUtils/shallowWithTheme.tsx +42ms
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/testUtils/shallowWithTheme.tsx +42ms
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/themes/darkTheme.ts +44ms
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/themes/darkTheme.ts +44ms
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/themes/ITheme.ts +35ms
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/themes/ITheme.ts +35ms
  typescript-eslint:typescript-estree:createProjectProgram Creating project program for: /home/dietmar/vsCodeProjects/smartHome.component-library/src/themes/lightTheme.ts +22ms
  typescript-eslint:typescript-estree:createWatchProgram Found existing program for file. /home/dietmar/vsCodeProjects/smartHome.component-library/src/themes/lightTheme.ts +22ms

/home/dietmar/vsCodeProjects/smartHome.component-library/src/docs/Introduction.stories.mdx
  0:0  warning  File ignored because of a matching ignore pattern. Use "--no-ignore" to override

✖ 1 problem (0 errors, 1 warning)

Done in 4.72s.
...