javascript - NPM: TypeScript dosyaları için geçerli bir kural belirtilmedi


Ben React.JS ile küçük bir proje yazıyorum. Her çalıştırdığımda : npm run start, bu kaydediliyor:

Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
Watching: /Users/John/Projects/myProject/src
Starting the development server...

ts-loader: Using [email  and /Users/John/Projects/myProject/tsconfig.json

TypeScript dosyaları için geçerli kural belirtilmemiş

Compiled successfully!
You can now view book-viewer-test in the browser.
Local:            http://localhost:3000/

Hatalı satırı işaretledim. Her şey iyi çalışıyor, ama projenin daha büyük ve daha karmaşık olduğunda etkisi olabileceğinden korkuyorum.

Bu uyarı/hata nedir? Bunu nasıl düzeltebilirim?

İşte benim tsconfig.json dosyam:

{
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "build/dist",
    "module": "esnext",
    "target": "es5",
    "lib": ["es7", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "rootDir": "src",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "experimentalDecorators": true
  },
  "exclude": [
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest",
    "src/setupTests.ts"
  ]
}

ve bir tslint.json dosyası var:

{
  "jsRules": {
    "no-empty": true
  }
}

Tavsiyeniz için teşekkür ederim.

Cevap #1

Sahip olduğunuz tek TSLint kuralları JavaScript dosyalarına uygulanır, TypeScript dosyalarına değil. TypeScript dosyalarını lintlemek için jsRules yerine rules kullanın.

{
  "rules": {
    "no-empty": true
  }
}

Cevap #2

Kullandığınız sürümleri kontrol etmelisiniz, büyük ihtimalle ciddi bir şey yok çünkü tanımlı kurallar yok! Her neyse, eğer react, npm, node güncelseniz, aşağı yukarı böyle bir çıktı almalısınız:

PS C:\React\my-app> npm run start

> [email  start C:\React\my-app
> react-scripts start
Starting the development server...
Compiled successfully!

You can now view my-app in the browser.

  Local:            http://localhost:3000/
  On Your Network:  http://192.168.1.67:3000/

Note that the development build is not optimized.
To create a production build, use npm run build.

İlgili makaleler