nestjs / schematics

Nest architecture element generation based on Angular schematics 🎬
https://nestjs.com
MIT License
388 stars 207 forks source link

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

Open Byron2016 opened 3 months ago

Byron2016 commented 3 months ago

Is there an existing issue that is already proposing this?

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 commented 3 months ago

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

Byron2016 commented 3 months ago

@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 commented 3 months ago

@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 commented 3 months ago

@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:

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 commented 2 months ago

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 commented 2 months ago

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

micalevisk commented 2 months ago

@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 commented 1 month ago

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

micalevisk commented 4 weeks ago

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

I guess we should downgrade eslint to v8 in the meantime

shvamabps commented 4 weeks ago

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 commented 3 weeks ago

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

shvamabps commented 2 weeks ago

Any tentative date when the upgrade will be released.

micalevisk commented 2 weeks ago

@shvamabps there is no ETA

shvamabps commented 17 hours ago

@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.