Skip to content

Commit

Permalink
fix: add back rules for import/first and import/order (#118)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: import first added back, so breaking from previous version that disabled it implicitely
BREAKING CHANGE: added import ordering

Co-authored-by: Benjamin SÉGAULT <Benjamin Ségault 8903454+bsegault@users.noreply.github.com>
  • Loading branch information
bsegault and Benjamin SÉGAULT committed Jul 11, 2023
1 parent 646ecca commit 9d28b36
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 5 deletions.
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 24 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 14 additions & 3 deletions sandbox.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}`);
};

0 comments on commit 9d28b36

Please sign in to comment.