Skip to content

Commit

Permalink
Migrate to eslint 9 and flat config (#2192)
Browse files Browse the repository at this point in the history
## Proposed change

Migrate to eslint 9 and flat config

Missing in this PR:
- [x] Review with the team the config exposed in `@o3r/eslint-config`
- [x] Fix errors due to the new config
- [x] Documentation:
   - [x]  Difference of rules between the 2 configs
   - [x]  Update global documentation (docs/linter/*)
- [x] fix ng-add @o3r/eslint-config
- [ ] fix `jsdoc/check-examples`
- [ ] Bonus: CLI to detect deprecated rules
  • Loading branch information
matthieu-crouzet authored Nov 28, 2024
2 parents ebfb189 + 71d72f0 commit 3a6a2d7
Show file tree
Hide file tree
Showing 2,269 changed files with 34,766 additions and 18,326 deletions.
15 changes: 0 additions & 15 deletions .eslintignore

This file was deleted.

126 changes: 0 additions & 126 deletions .eslintrc.js

This file was deleted.

21 changes: 20 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"package.json": "ng-package.json, project.json, yarn.lock, .yarnrc.yml, .npmrc, .npmrc.*, .pnp.*",
"nx.json": ".nxignore",
".eslintrc.*": ".eslintignore, .eslintrc-*",
"eslint.config.mjs": "eslint.*.config.mjs",
"jest.config.js": "jest.config.*",
"Dockerfile*": ".dockerignore"
},
Expand Down Expand Up @@ -97,5 +98,23 @@
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": false,
"otter.extract.styling.prefix": "o3r",
"typescript.tsserver.watchOptions": "vscode"
"typescript.tsserver.watchOptions": "vscode",
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.foldingImportsByDefault": true,
"eslint.useFlatConfig": true,
"eslint.rules.customizations": [
{
"rule": "@stylistic/*",
"fixable": true,
"severity": "off"
},
{
"rule": "!@stylistic/*",
"fixable": true,
"severity": "info"
}
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
32 changes: 32 additions & 0 deletions .yarn/sdks/eslint/lib/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real eslint your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint`));
32 changes: 32 additions & 0 deletions .yarn/sdks/eslint/lib/types/rules/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/rules
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real eslint/rules your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/rules`));
32 changes: 32 additions & 0 deletions .yarn/sdks/eslint/lib/types/universal.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/universal
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real eslint/universal your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/universal`));
32 changes: 32 additions & 0 deletions .yarn/sdks/eslint/lib/types/use-at-your-own-risk.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/use-at-your-own-risk
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real eslint/use-at-your-own-risk your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/use-at-your-own-risk`));
32 changes: 32 additions & 0 deletions .yarn/sdks/eslint/lib/universal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, register} = require(`module`);
const {resolve} = require(`path`);
const {pathToFileURL} = require(`url`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`);
const absRequire = createRequire(absPnpApiPath);

const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require eslint/universal
require(absPnpApiPath).setup();
if (isPnpLoaderEnabled && register) {
register(pathToFileURL(absPnpLoaderPath));
}
}
}

const wrapWithUserWrapper = existsSync(absUserWrapperPath)
? exports => absRequire(absUserWrapperPath)(exports)
: exports => exports;

// Defer to the real eslint/universal your application uses
module.exports = wrapWithUserWrapper(absRequire(`eslint/universal`));
19 changes: 16 additions & 3 deletions .yarn/sdks/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
{
"name": "eslint",
"version": "8.57.1-sdk",
"version": "9.14.0-sdk",
"main": "./lib/api.js",
"type": "commonjs",
"bin": {
"eslint": "./bin/eslint.js"
},
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"default": "./lib/api.js"
},
"./package.json": "./package.json",
".": "./lib/api.js",
"./use-at-your-own-risk": "./lib/unsupported-api.js"
"./use-at-your-own-risk": {
"types": "./lib/types/use-at-your-own-risk.d.ts",
"default": "./lib/unsupported-api.js"
},
"./rules": {
"types": "./lib/types/rules/index.d.ts"
},
"./universal": {
"types": "./lib/types/universal.d.ts",
"default": "./lib/universal.js"
}
}
}
9 changes: 9 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ packageExtensions:
"@swc-node/register@^1.9.0":
dependencies:
"@swc/types": "*"
"@typescript-eslint/rule-tester@*":
dependencies:
"@typescript-eslint/parser": "~8.12.2"
"angular-eslint@*":
dependencies:
"@typescript-eslint/utils": ~8.12.2
"@angular-eslint/eslint-plugin-template@*":
dependencies:
"@typescript-eslint/types": "^8.0.0"
probot@*:
peerDependencies:
"@types/express-serve-static-core": ^4.19.5
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ When contributing, please keep in mind the following rules:
To ease the process, we are providing a set of:

- [Editors configuration](.editorconfig)
- [Linters configuration](./packages/@o3r/eslint-config-otter/README.md)
- [Linters configuration](./packages/@o3r/eslint-config/README.md)
- [Component generator](./packages/@o3r/core/README.md#generators) (and more)

### Accelerate your build thanks to Nx Cloud
Expand Down
Loading

0 comments on commit 3a6a2d7

Please sign in to comment.