diff --git a/.eslintrc.js b/.eslintrc.js index 5af32b0..4f4b626 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -65,6 +65,22 @@ module.exports = { // Enforced // curly: "warn", + // Force import first + "import/first": "warn", + "import/order": [ + "warn", + { + groups: ["builtin", "external"], + pathGroups: [ + { + pattern: "@epconnect/**", + group: "external", + position: "after", + }, + ], + "newlines-between": "always-and-inside-groups", + }, + ], // Set console calls to emit warnings as not enabled by eslint:recommended "no-console": "warn", // enforce types diff --git a/config.json b/config.json index 71a8410..be26dae 100644 --- a/config.json +++ b/config.json @@ -18,19 +18,41 @@ "project": "./tsconfig.json" }, "plugins": [ - "@typescript-eslint", "sonarjs", "react-hooks", "react", "jsx-a11y", "import", - "flowtype" + "flowtype", + "@typescript-eslint" ], "reportUnusedDisableDirectives": true, "rules": { "curly": [ "warn" ], + "import/first": [ + "warn" + ], + "import/order": [ + "warn", + { + "groups": [ + "builtin", + "external" + ], + "pathGroups": [ + { + "pattern": "@epconnect/**", + "group": "external", + "position": "after" + } + ], + "newlines-between": "always-and-inside-groups", + "distinctGroup": true, + "warnOnUnassignedImports": false + } + ], "no-console": [ "warn" ], diff --git a/package-lock.json b/package-lock.json index cf08c1f..48a843b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "eslint-plugin-sonarjs": "^0.19.0" }, "devDependencies": { + "@types/node": "^16.18.23", "conventional-changelog-conventionalcommits": "^5.0.0", "eslint": "^8.39.0", "prettier": "^2.8.8", @@ -1458,6 +1459,12 @@ "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==", "dev": true }, + "node_modules/@types/node": { + "version": "16.18.23", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.23.tgz", + "integrity": "sha512-XAMpaw1s1+6zM+jn2tmw8MyaRDIJfXxqmIQIS0HfoGYPuf7dUWeiUKopwq13KFX9lEp1+THGtlaaYx39Nxr58g==", + "dev": true + }, "node_modules/@types/normalize-package-data": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz", @@ -10762,6 +10769,12 @@ "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==", "dev": true }, + "@types/node": { + "version": "16.18.23", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.23.tgz", + "integrity": "sha512-XAMpaw1s1+6zM+jn2tmw8MyaRDIJfXxqmIQIS0HfoGYPuf7dUWeiUKopwq13KFX9lEp1+THGtlaaYx39Nxr58g==", + "dev": true + }, "@types/normalize-package-data": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz", diff --git a/package.json b/package.json index 4eb4ba7..29b9762 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "eslint-plugin-sonarjs": "^0.19.0" }, "devDependencies": { + "@types/node": "^16.18.23", "conventional-changelog-conventionalcommits": "^5.0.0", "eslint": "^8.39.0", "prettier": "^2.8.8", diff --git a/sandbox.ts b/sandbox.ts index f65b188..2735b2d 100644 --- a/sandbox.ts +++ b/sandbox.ts @@ -1,6 +1,16 @@ // A dummy files to test manually rules +/* eslint-disable no-console */ + +import _json5 from "json5"; + +const first = 0; + +// eslint-disable-next-line import/first +import pkg from "./package.json"; + +// eslint-disable-next-line import/first, import/order +import fs from "fs"; -// eslint-disable-next-line no-console console.log("hello"); // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -9,8 +19,9 @@ const empty = 1; // eslint-disable-next-line @typescript-eslint/no-explicit-any let dummy: any; +console.log(fs.readSync); + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types export const getDummy = (param: unknown) => { - // eslint-disable-next-line no-console - console.log(`${dummy} and ${param}`); + console.log(`${dummy} and ${param} a, ${first}, ${pkg.version}`); };