Skip to content

Commit

Permalink
chore: migrate to eslint9 (scaleway#1529)
Browse files Browse the repository at this point in the history
  • Loading branch information
jremy42 authored Nov 4, 2024
1 parent 24e27b4 commit 6b3485c
Show file tree
Hide file tree
Showing 7 changed files with 2,376 additions and 5,198 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

46 changes: 0 additions & 46 deletions .eslintrc

This file was deleted.

109 changes: 109 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import tsdoc from "eslint-plugin-tsdoc";
import typescriptParser from "@typescript-eslint/parser";
import scwTypescript from '@scaleway/eslint-config-react/typescript';


const scwPlugins = scwTypescript.reduce((acc, config) => {
return { ...acc, ...config.plugins };
}, {});

export default [
{
ignores: [
"**/node_modules/",
"**/dist/",
"**/examples/",
"**/vite.config.ts",
"packages/clients/.eslintrc.cjs",
"eslint.config.mjs",
"packages/clients/src/vendor/base64/index.js",
"packages/configuration-loader/.eslintrc.cjs",

],
},
{
languageOptions: {
ecmaVersion: 5,
sourceType: "script",
parser: typescriptParser,
parserOptions: {
project: ["tsconfig.json"],
},
},
plugins: {
tsdoc,
...scwPlugins,
},
rules: {
"tsdoc/syntax": "warn",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "enumMember",
format: ["PascalCase"],
},
],
"import/prefer-default-export": "off",
"import/no-default-export": "error",
"no-await-in-loop": "off",
"@typescript-eslint/no-namespace": "off",
},
},

...scwTypescript.map(config => ({
...config,
files: ['**/*.ts', '**/*.tsx'],
rules: {
...config.rules,
//new rules
"no-restricted-syntax": "warn",
"no-useless-escape": "warn",
"max-classes-per-file": "warn",
"no-underscore-dangle": "warn",
"no-await-in-loop": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/consistent-type-definitions": "warn",
"@typescript-eslint/ban-types": "warn",
},
})),

...scwTypescript.map(config => ({
...config,
files: [
"./packages/clients/src/scw/**/*.ts",
"./packages/clients/src/internal/**/*.ts",
],
rules: {
...config.rules,
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/consistent-type-definitions": "off",
},

})),

...scwTypescript.map(config => ({
...config,
files: ["**/*.test.ts", "__tests__/**/*.ts", "**/vite.config.ts"],
rules: {
...config.rules,
"import/no-extraneous-dependencies": "off",
},

})),

...scwTypescript.map(config => ({
...config,
files: ["packages/clients/src/api/dedibox/v1/*.ts"],
rules: {
...config.rules,
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"max-classes-per-file": "off",
"no-restricted-syntax": "off",
},

})),

];
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"commit": "npx git-cz -a",
"doc": "typedoc",
"format": "prettier --write '**/*.ts'",
"lint": "eslint --cache --ext ts .",
"lint": "eslint --cache .",
"prepare": "husky",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
Expand All @@ -24,7 +24,7 @@
"lint-staged": {
"*.ts": [
"prettier --write",
"eslint --fix --ext ts"
"eslint --fix ."
],
"*.yaml": [
"prettier --write"
Expand All @@ -46,7 +46,8 @@
"devDependencies": {
"@commitlint/cli": "19.5.0",
"@commitlint/config-conventional": "19.5.0",
"@scaleway/eslint-config-react": "3.18.4",
"@scaleway/eslint-config-react": "4.0.8",
"@typescript-eslint/eslint-plugin": "latest",
"@vitest/coverage-istanbul": "2.0.5",
"@vitest/coverage-v8": "2.0.5",
"@vitest/ui": "2.0.5",
Expand All @@ -56,7 +57,7 @@
"cross-fetch": "4.0.0",
"cz-conventional-changelog": "3.3.0",
"esbuild-plugin-browserslist": "0.14.0",
"eslint": "8.57.0",
"eslint": "9.7.0",
"eslint-plugin-tsdoc": "0.3.0",
"husky": "9.1.6",
"jsdom": "25.0.0",
Expand Down
Loading

0 comments on commit 6b3485c

Please sign in to comment.