Вот импорт, с которым я вижу это:
import { HttpClient } from '@angular/common/http';
import { ConfirmationService, MessageService } from "primeng/api";
Я вижу ошибку:
ESLint: Parse errors in imported module '@angular/common/http': Cannot read property 'name' of undefined (undefined:undefined)(import/namespace)
и
ESLint: Parse errors in imported module 'primeng/api': Cannot read property 'name' of undefined (undefined:undefined)(import/namespace)
Вот мой .eslint. json:
{
"env": {
"browser": true,
"es6": true,
"node": true,
"jasmine": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:jasmine/recommended"
],
"settings": {
"import/parsers": { "@typescript-eslint/parser": [".ts"] },
"import/resolver": {
"typescript": {
"directory": "./"
}
}
},
"overrides": [
{
"files": ["*.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"allowImportExportEverywhere": true,
"ecmaVersion": 2020,
"project": "./tsconfig.json",
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"arrowFunctions": true,
"classes": true
}
},
"plugins": [
"@typescript-eslint",
"@angular-eslint",
"@typescript-eslint/tslint",
"import",
"jsdoc",
"prefer-arrow",
"jasmine"
],
"rules": {
"@angular-eslint/component-class-suffix": "error",
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
],
"@angular-eslint/contextual-lifecycle": "error",
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/no-conflicting-lifecycle": "error",
"@angular-eslint/no-host-metadata-property": "error",
"@angular-eslint/no-input-rename": "error",
"@angular-eslint/no-output-native": "error",
"@angular-eslint/no-output-on-prefix": "error",
"@angular-eslint/no-output-rename": "error",
"@angular-eslint/no-outputs-metadata-property": "error",
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/indent": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/member-ordering": [
"error",
{
"default": ["static-field", "instance-field", "static-method", "instance-method"]
}
],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/quotes": ["error", "single"],
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/tslint/config": [
"error",
{
"rules": {
"directive-class-suffix": true,
"jsdoc-format": true,
"lines-between-class-members": true,
"no-reference-import": true,
"no-unused-variable": true,
"template-banana-in-box": true,
"template-no-negated-async": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": true
}
}
],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"array-bracket-spacing": ["error", "never"],
"arrow-body-style": "error",
"arrow-parens": ["off", "as-needed"],
"block-spacing": "error",
"brace-style": "error",
"camelcase": "error",
"comma-dangle": "off",
"comma-spacing": "error",
"comma-style": ["error", "last"],
"complexity": "off",
"constructor-super": "error",
"curly": "error",
"dot-notation": "error",
"eol-last": "off",
"eqeqeq": ["error", "smart"],
"getter-return": "error",
"guard-for-in": "error",
"id-blacklist": [
"error",
"any",
"Number",
"number",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined"
],
"id-match": "error",
"import/no-deprecated": "off",
"import/order": "error",
"jsdoc/no-types": "error",
"linebreak-style": "off",
"lines-between-class-members": [
"error",
"always",
{
"exceptAfterSingleLine": true
}
],
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "*",
"next": "return"
},
{
"blankLine": "always",
"prev": "*",
"next": "if"
},
{
"blankLine": "always",
"prev": "if",
"next": "*"
},
{
"blankLine": "always",
"prev": "block-like",
"next": "block-like"
},
{
"blankLine": "always",
"prev": "try",
"next": "*"
},
{
"blankLine": "always",
"prev": "*",
"next": "try"
},
{
"blankLine": "always",
"prev": "do",
"next": "*"
},
{
"blankLine": "always",
"prev": "*",
"next": "do"
},
{
"blankLine": "always",
"prev": "const",
"next": "*"
},
{
"blankLine": "always",
"prev": "while",
"next": "*"
},
{
"blankLine": "always",
"prev": "*",
"next": "while"
},
{
"blankLine": "always",
"prev": "for",
"next": "*"
},
{
"blankLine": "always",
"prev": "*",
"next": "for"
},
{
"blankLine": "always",
"prev": "const",
"next": "*"
},
{
"blankLine": "never",
"prev": "const",
"next": "const"
},
{
"blankLine": "always",
"prev": "let",
"next": "*"
},
{
"blankLine": "never",
"prev": "let",
"next": "let"
},
{
"blankLine": "always",
"prev": "import",
"next": "*"
},
{
"blankLine": "never",
"prev": "import",
"next": "import"
},
{
"blankLine": "never",
"prev": "export",
"next": "export"
},
{
"blankLine": "always",
"prev": "export",
"next": "*"
},
{
"blankLine": "always",
"prev": "*",
"next": "continue"
},
{
"blankLine": "always",
"prev": "*",
"next": "throw"
},
{
"blankLine": "always",
"prev": "multiline-const",
"next": "*"
},
{
"blankLine": "always",
"prev": "*",
"next": "multiline-const"
}
],
"max-classes-per-file": "error",
"max-len": [
"error",
{
"code": 140
}
],
"new-parens": "error",
"newline-per-chained-call": "off",
"no-await-in-loop": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": [
"error",
{
"allow": [
"log",
"dirxml",
"warn",
"error",
"dir",
"timeLog",
"assert",
"clear",
"count",
"countReset",
"group",
"groupCollapsed",
"groupEnd",
"table",
"Console",
"markTimeline",
"profile",
"profileEnd",
"timeline",
"timelineEnd",
"timeStamp",
"context"
]
}
],
"no-constant-condition": "error",
"no-debugger": "error",
"no-else-return": "error",
"no-empty": "error",
"no-eval": "error",
"no-extra-semi": "error",
"no-fallthrough": "error",
"no-implicit-coercion": "error",
"no-invalid-this": "error",
"no-lonely-if": "error",
"no-irregular-whitespace": "off",
"no-magic-numbers": "error",
"no-mixed-operators": "error",
"no-multiple-empty-lines": "error",
"no-multi-assign": "error",
"no-new": "error",
"no-new-wrappers": "error",
"no-param-reassign": "error",
"no-restricted-imports": ["error", "rxjs/Rx"],
"no-return-assign": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-shadow": [
"error",
{
"hoist": "all"
}
],
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-unmodified-loop-condition": "error",
"no-unreachable": "error",
"no-restricted-exports": [
"error",
{
"restrictedNamedExports": ["default"]
}
],
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-unused-vars": "error",
"no-useless-catch": "error",
"no-useless-return": "error",
"no-var": "error",
"object-shorthand": "error",
"one-var": ["error", "never"],
"prefer-arrow/prefer-arrow-functions": "error",
"prefer-const": "error",
"prefer-destructuring": "error",
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-template": "error",
"quote-props": ["error", "as-needed"],
"radix": "error",
"require-await": "error",
"space-before-function-paren": ["error", "never"],
"space-in-parens": ["error", "never"],
"spaced-comment": "error",
"use-isnan": "error",
"valid-typeof": "off",
"yoda": "error"
}
},
{
"files": ["*.component.html"],
"parser": "@angular-eslint/template-parser",
"plugins": ["@angular-eslint/template"],
"rules": {
// ORIGINAL tslint.json -> "template-banana-in-box": true,
"@angular-eslint/template/banana-in-a-box": "error",
// ORIGINAL tslint.json -> "template-no-negated-async": true,
"@angular-eslint/template/no-negated-async": "error"
}
},
{
"files": ["*.component.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": ["@angular-eslint/template"],
"processor": "@angular-eslint/template/extract-inline-html"
}
]
}
Вот мой .tsconfig. json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@library/*": ["src/app/projects/library/*"],
"@agreement/*": ["src/app/projects/agreement/*"],
"@customer/*": ["src/app/projects/customer/*"],
"@carrier/*": ["src/app/projects/carrier/*"],
"@ltl/*": ["src/app/projects/ltl/*"],
"@rail/*": ["src/app/projects/rail/*"]
},
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "ESNext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom"],
"emitDecoratorMetadata": false
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
},
"exclude": ["node_modules"]
}
Я немного поиграл с parserOptions
. То, что вы видите, это то, что я пытался, но это не помогло. Я искал в Google и ничего не нашел. Это может быть проблема, связанная со спецификацией * WebStorm c, поскольку я не могу воспроизвести ее с помощью VSCode.
Дайте мне знать, если вам что-то еще понадобится, чтобы помочь мне. Я могу предоставить снимки экрана с моими настройками WebStorm. Любая помощь будет оценена.