Expects includes in excludes in tsconfig.json while the property is include and exclude
wisammechano opened this issue ยท 5 comments
๐ Bug Report
tslint-to-eslint-configversion: 2.14.0- ESLint version: 8.38.0
- Node version: 16.18.0
Actual Behavior
Running with --comments modifier removed the tslint comments in some 100+ files (from output message) when the project doesn't have this number of files. It was traversing node_modules as well which isn't in the include config in tsconfig.json.
After some testing, I changed include to includes and now the config was respected (only 48 files were converted) which were inside ./src/**
Expected Behavior
Should respect the config as include and exclude and only traverse the included files when converting comments
Reproduction
The npx .. command was run in a directory with express and typescript source files. tsconfig.json is attached below.
The project structure is a mono repo with multiple subdirs:
- .git
- server
- src
- node_modules
- dist
- tsconfig.json
- tslint.json
- ...
- client
- ...
The command run and tsconfig.json are both inside ./server subdir.
tsconfig.json
{
"compilerOptions": {
"target": "ES2021",
"module": "CommonJS",
"esModuleInterop": true,
"lib": ["ES2021", "DOM"],
"sourceMap": true,
"inlineSources": true,
"outDir": "dist",
"strict": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"importHelpers": true,
"declaration": true,
"incremental": true,
"removeComments": true,
"skipLibCheck": true,
"rootDir": "src",
"sourceRoot": "src",
"typeRoots": ["node_modules/@types"],
"baseUrl": ".",
"paths": {
"#*": ["src/*"]
}
},
"include": ["src/**/*.ts"]
}Oh very interesting, thank you for posting @wisammechano! I think I see what you're saying but am not 100% sure. Would you be able to please post the origin tslint.json(s) and package.json(s)? Or even better, is the project open source / something you could pare down to a reproduction repo?
Unfortunately the project isn't open source, so I can't share it. But here's tslint.json placed inside <RepoRoot>/server and beside tsconfig.json
{
"defaultSeverity": "error",
"extends": ["tslint:recommended", "tslint-config-prettier"],
"linterOptions": {
"exclude": ["node_modules"]
},
"jsRules": {},
"rules": {},
"rulesDirectory": []
}this is also package.json placed beside tslint.json for the server package. FYI this is package.json before running the tslint-to-eslint-config command.
{
"name": "backend-express",
"version": "1.0.0",
"main": "dist/index.js",
"author": "Wisam Naji",
"scripts": {
"prebuild": "yarn run lint",
"lint": "tslint -c tslint.json -p tsconfig.json --fix",
"prettier": "prettier --check ./src/**/*.ts",
"build": "tsc",
"prestart": "yarn run build",
"start": "node .",
"start:built": "node .",
"start:pm2": "pm2 start",
"start:pm2rt": "pm2-runtime ecosystem.config.js",
"dev": "nodemon",
"debug": "nodemon --inspect",
"test": "jest",
"prepare": "cd .. && husky install server/.husky"
},
"lint-staged": {
"*.ts": [
"yarn run lint",
"prettier --write ./src/**/*.ts"
]
},
"nodemonConfig": {
"ignore": [
"**/*.test.ts",
"**/*.spec.ts",
"node_modules"
],
"watch": [
"src"
],
"exec": "node -r tsconfig-paths/register -r ts-node/register ./src/index.ts",
"ext": "ts, js"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.301.0",
"@aws-sdk/s3-request-presigner": "^3.303.0",
"@googleapis/people": "^3.0.2",
"@sentry/node": "^7.0.0",
"@sentry/tracing": "^7.0.0",
"body-parser": "^1.20.0",
"cookie-parser": "^1.4.6",
"csv-parser": "^3.0.0",
"dayjs": "^1.11.4",
"dotenv": "^16.0.1",
"encrypt-cookie": "^1.1.5",
"express": "^4.18.1",
"express-async-handler": "^1.2.0",
"express-jwt": "^7.7.3",
"google-auth-library": "^8.7.0",
"joi": "^17.7.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^7.0.3",
"multer": "^1.4.5-lts.1",
"nanoid": "^3.3.4",
"passport": "^0.6.0",
"passport-google-verify-token": "^2.2.0",
"pm2": "^5.2.0",
"timezone-soft": "^1.4.1"
},
"devDependencies": {
"@types/body-parser": "^1.19.2",
"@types/cookie-parser": "^1.4.3",
"@types/express": "^4.17.13",
"@types/express-unless": "^0.5.3",
"@types/jsonwebtoken": "^8.5.8",
"@types/multer": "^1.4.7",
"@types/node": "^18.15.11",
"@types/passport": "^1.0.11",
"husky": "^8.0.1",
"jest": "^29.5.0",
"lint-staged": "^13.0.1",
"nodemon": "^2.0.16",
"prettier": "2.6.2",
"ts-node": "^10.8.0",
"tsconfig-paths": "^4.2.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.7.2"
}
}Hmm, I can't seem to reproduce. I have the following files:
cool/file.ts
let a = 3;
/* tslint:disable */
let b = 4;other/file.ts
tsconfig.json
{
"include": ["other"]
}When I run tslint-to-eslint-config --config .eslintrc.json --convert, it does not replace the TSLint directive.
However, when I do "include": ["cool"] or "include": ["cool/*.ts"], it does replace it.
I think some of the confusion stems from description of the behavior of --comments in the readme. It says it respects excludes and includes, when it actually expects exclude and include (which is the correct behavior, since neither excludes nor includes are valid keys in tsconfig.json)
I marked the linked PR as closing this issue because the expected behavior mentioned here matches the behavior I got when testing, and the confusion seems to be from the documentation (which is fixed in the PR)