Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nest-cli new will generate an scaffolding with eslint V9.9.0 #1909

Closed
1 task done
Byron2016 opened this issue Aug 24, 2024 · 15 comments
Closed
1 task done

nest-cli new will generate an scaffolding with eslint V9.9.0 #1909

Byron2016 opened this issue Aug 24, 2024 · 15 comments
Labels

Comments

@Byron2016
Copy link

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Currently when we run pnpx @nestjs/cli new it is generated a nestjs scaffolding with "eslint": "^8.42.0" and eslintrc.js file, it is necessary to update to new FLAT FILE WITH "eslint": "^9.9.0"

Describe the solution you'd like

to update to new FLAT FILE WITH "eslint": "^9.9.0"

Teachability, documentation, adoption, migration strategy

.

What is the motivation / use case for changing the behavior?

to make use of new eslint's FLAT file simplicity

@micalevisk
Copy link
Member

What is that flat file? 🤔 I never saw this expression before sorry

@Byron2016
Copy link
Author

@micalevisk ESLint made a breaking change with V9. Now it works with eslint.config.js that named flat file / flat config instead of .eslintrc.js Start Using Flat Config Files. This new configuration has some ventages because ESLint is trying to made more easy its configuration and integration with other plugings, configs, formarters, etc.

@micalevisk
Copy link
Member

@Byron2016 would you like to create a PR to address this? It should be done at https://github.com/nestjs/schematics/blob/master/src/lib/application/files/ts/package.json and related files in that directory

@Byron2016
Copy link
Author

Byron2016 commented Aug 25, 2024

@micalevisk I am not sure about PR because I have some dudes about eslint configuration, but here are the steps that are needed to do:

I think it is necesary to do this changes:

  • package.json

    • Add scripts:
      • "format:check": "prettier --check "src//*.ts" "test//*.ts"",
      • "lint:nofix": "eslint "{src,apps,libs,test}/**/*.ts" ",
      • "lint:inspect": "eslint --inspect-config",
    • update devDependencies
      • "eslint": "^9.9.1",
      • "eslint-config-prettier": "^9.1.0",
      • "prettier": "^3.3.3",
    • add devDependencies
      • "@eslint/js": "^9.9.1",
      • "globals": "^15.9.0",
      • "typescript-eslint": "^8.3.0"
      • "eslint-plugin-jest": "^28.8.0",
    • remove devDependencies
      • "@typescript-eslint/eslint-plugin" and "@typescript-eslint/parser"
        • Because typescript-eslint already has devDependencies on @typescript-eslint/eslint-plugin and @typescript-eslint/parser
      • "eslint-plugin-prettier": "^5.0.0",
        • This plugin was especially useful when Prettier was new. By running Prettier inside your linters, you didn’t have to set up any new infrastructure and you could re-use your editor integrations for the linters. But these days you can run prettier --check . and most editors have Prettier support. eslint-plugin-prettier
  • tsconfig.json

    • update to true:
    • "strictNullChecks": true,
  • Eslint

    • remove .eslintrc.js
    • add eslint.config.js
    • This is eslint.config.js file content, but it is necessary to validate with another one with more experience with ESLint
const eslint = require('@eslint/js');
const globals = require('globals');

const tseslint = require('typescript-eslint');

const eslintConfigPrettier = require('eslint-config-prettier');

module.exports = [
  {
    ignores: ['**/eslint.config.js'],
  },

  eslint.configs.recommended,
  ...tseslint.configs.recommendedTypeChecked,
  ...tseslint.configs.stylisticTypeChecked,
  eslintConfigPrettier,

  {
    languageOptions: {
      globals: {
        ...globals.node,
        ...globals.jest,
      },

      parser: tseslint.parser,
      parserOptions: {
        projectService: true,
        tsconfigRootDir: __dirname,
      },
    },
    // Rules
    rules: {
      '@typescript-eslint/explicit-function-return-type': 'off',
      '@typescript-eslint/explicit-module-boundary-types': 'off',
      '@typescript-eslint/interface-name-prefix': 'off',
      '@typescript-eslint/no-explicit-any': 'off',
    },
  },
];

@shvamabps
Copy link

Also, nest cli generates code with outdated packages.
Current Package Version

"dependencies": {
    "@nestjs/common": "^10.0.0",
    "@nestjs/core": "^10.0.0",
    "@nestjs/platform-express": "^10.0.0",
    "reflect-metadata": "^0.2.0",
    "rxjs": "^7.8.1"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.0.0",
    "@nestjs/schematics": "^10.0.0",
    "@nestjs/testing": "^10.0.0",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.5.2",
    "@types/node": "^20.3.1",
    "@types/supertest": "^6.0.0",
    "@typescript-eslint/eslint-plugin": "^8.0.0",
    "@typescript-eslint/parser": "^8.0.0",
    "eslint": "^8.42.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-prettier": "^5.0.0",
    "jest": "^29.5.0",
    "prettier": "^3.0.0",
    "source-map-support": "^0.5.21",
    "supertest": "^7.0.0",
    "ts-jest": "^29.1.0",
    "ts-loader": "^9.4.3",
    "ts-node": "^10.9.1",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.1.3"
  },

Package versions should be

"dependencies": {
    "@nestjs/common": "^10.4.3",
    "@nestjs/core": "^10.4.3",
    "@nestjs/platform-express": "^10.4.3",
    "reflect-metadata": "^0.2.2",
    "rxjs": "^7.8.1"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.4.5",
    "@nestjs/schematics": "^10.1.4",
    "@nestjs/testing": "^10.4.3",
    "@types/express": "^4.17.21",
    "@types/jest": "^29.5.13",
    "@types/node": "^22.5.5",
    "@types/supertest": "^6.0.2",
    "@typescript-eslint/eslint-plugin": "^8.6.0",
    "@typescript-eslint/parser": "^8.6.0",
    "eslint": "^9.11.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "jest": "^29.7.0",
    "prettier": "^3.3.3",
    "source-map-support": "^0.5.21",
    "supertest": "^7.0.0",
    "ts-jest": "^29.2.5",
    "ts-loader": "^9.5.1",
    "ts-node": "^10.9.2",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^5.6.2"
  }

For the default code generated by the nestjs new command.

@shvamabps
Copy link

While the base packages are getting updated, the cli packages are not getting updated.

@micalevisk
Copy link
Member

@shvamabps we got a bunch of PRs open to address that. Those semver ranges are updates by the Renovate bot from time to time

@nesffer
Copy link

nesffer commented Oct 10, 2024

Any update? ESLint v8 version is no longer supported soon.

@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/nest-cli Oct 21, 2024
@micalevisk
Copy link
Member

micalevisk commented Oct 26, 2024

We will upgrade that config file in the next major release.

I guess we should downgrade eslint to v8 in the meantime

@shvamabps
Copy link

Is it possible to update the tsconfig file where it enforces and strictly type saves the entire code base. Also, the eslint and prettier config files are modified respectively with the best code practices.

@TaeyoonKwon
Copy link

nest new will scaffold a project with eslint^9 but generates .eslintrc.js file which is not compatible with eslint^9.

@shvamabps
Copy link

Any tentative date when the upgrade will be released.

@micalevisk
Copy link
Member

@shvamabps there is no ETA

@shvamabps
Copy link

@micalevisk actually the version that is present in the nestjs is a bit old for even the nestjs related packages. The eslint, etc related dev deps and deps are behind the version.

@kamilmysliwiec
Copy link
Member

#1945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants