Skip to content

Commit

Permalink
chore: set eslint import/order
Browse files Browse the repository at this point in the history
  • Loading branch information
ocamilomontealegre committed Dec 5, 2024
1 parent 07e957d commit 28e47d1
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 172 deletions.
343 changes: 175 additions & 168 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,177 +5,184 @@ import pluginJs from "@eslint/js";
import typescriptEslint from "typescript-eslint";
import tsParser from "@typescript-eslint/parser";
import cspellPlugin from "@cspell/eslint-plugin";
import importOrderPlugin from "eslint-plugin-import";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

export default typescriptEslint.config(
{
files: ["**/*.{js,mjs,cjs,ts}"],
languageOptions: {
globals: {
...globals.node,
},
parser: tsParser,
ecmaVersion: 2020,
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
sourceType: "module",
},
},
settings: {
node: {
allow: ["process", "Buffer"],
},
},
ignores: [
"dist",
"node_modules",
"eslint.config.js",
"vitest.config.ts",
"commitlint.config.ts",
],
plugins: {
"@cspell": cspellPlugin,
},
extends: [pluginJs.configs.recommended, ...typescriptEslint.configs.recommended],
rules: {
"no-duplicate-imports": "error",
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/ban-tslint-comment": "error",
"@typescript-eslint/class-literal-property-style": "error",
"@typescript-eslint/consistent-generic-constructors": "error",
"@typescript-eslint/consistent-indexed-object-style": "error",
"@typescript-eslint/consistent-type-assertions": [
"error",
{
assertionStyle: "as",
},
],
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": [
"error",
{
prefer: "type-imports",
},
],
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-member-accessibility": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-duplicate-type-constituents": "error",
"@typescript-eslint/no-extra-non-null-assertion": "error",
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/prefer-reduce-type-parameter": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/prefer-readonly": "error",
"no-return-await": "off",
"@typescript-eslint/return-await": "error",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unbound-method": ["off", { "ignore-static": true }],
"@typescript-eslint/unbound-method": ["off"],
"@typescript-eslint/no-floating-promises": "off",
eqeqeq: ["error", "always"],
"no-console": "error",
"@typescript-eslint/unified-signatures": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/naming-convention": [
"error",
{
selector: "default",
format: ["camelCase"],
},
{
selector: "variable",
format: ["camelCase", "UPPER_CASE", "PascalCase"],
leadingUnderscore: "allow",
},
{
selector: "parameter",
format: ["camelCase"],
leadingUnderscore: "allow",
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase", "UPPER_CASE", "snake_case"],
leadingUnderscore: "allow",
},
{
selector: "memberLike",
modifiers: ["public"],
format: ["camelCase", "UPPER_CASE", "snake_case"],
},
{
selector: "typeLike",
format: ["PascalCase"],
},
{
selector: "enumMember",
format: ["UPPER_CASE"],
},
{
selector: "objectLiteralMethod",
format: ["camelCase", "PascalCase"],
},
{
selector: "objectLiteralProperty",
format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"],
leadingUnderscore: "allow",
},
{
selector: "typeProperty",
format: ["camelCase", "UPPER_CASE", "snake_case"],
leadingUnderscore: "allow",
},
],
export default typescriptEslint.config({
files: ["**/*.{js,mjs,cjs,ts}"],
languageOptions: {
globals: {
...globals.node,
},
parser: tsParser,
ecmaVersion: 2020,
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
sourceType: "module",
},
},
settings: {
node: {
allow: ["process", "Buffer"],
},
},
ignores: [
"dist/",
"node_modules",
"vitest.config.ts",
"commitlint.config.ts",
"*.mjs",
"**/.husky/*",
],
plugins: {
import: importOrderPlugin,
"@cspell": cspellPlugin,
},
extends: [pluginJs.configs.recommended, ...typescriptEslint.configs.recommended],
rules: {
"no-duplicate-imports": "error",
"import/order": [
"error",
{
groups: [["builtin", "external", "internal", "parent", "sibling"], ["type"]],
},
],
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/ban-tslint-comment": "error",
"@typescript-eslint/class-literal-property-style": "error",
"@typescript-eslint/consistent-generic-constructors": "error",
"@typescript-eslint/consistent-indexed-object-style": "error",
"@typescript-eslint/consistent-type-assertions": [
"error",
{
assertionStyle: "as",
},
],
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": [
"error",
{
prefer: "type-imports",
},
],
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-member-accessibility": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-duplicate-type-constituents": "error",
"@typescript-eslint/no-extra-non-null-assertion": "error",
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/prefer-reduce-type-parameter": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/prefer-readonly": "error",
"no-return-await": "off",
"@typescript-eslint/return-await": "error",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unbound-method": ["off", { "ignore-static": true }],
"@typescript-eslint/unbound-method": ["off"],
"@typescript-eslint/no-floating-promises": "off",
eqeqeq: ["error", "always"],
"no-console": "error",
"@typescript-eslint/unified-signatures": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/naming-convention": [
"error",
{
selector: "default",
format: ["camelCase"],
},
{
selector: "variable",
format: ["camelCase", "UPPER_CASE", "PascalCase"],
leadingUnderscore: "allow",
},
{
selector: "parameter",
format: ["camelCase"],
leadingUnderscore: "allow",
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase", "UPPER_CASE", "snake_case"],
leadingUnderscore: "allow",
},
{
selector: "memberLike",
modifiers: ["public"],
format: ["camelCase", "UPPER_CASE", "snake_case"],
},
{
selector: "typeLike",
format: ["PascalCase"],
},
{
selector: "enumMember",
format: ["UPPER_CASE"],
},
{
selector: "objectLiteralMethod",
format: ["camelCase", "PascalCase"],
},
{
selector: "objectLiteralProperty",
format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"],
leadingUnderscore: "allow",
},
{
selector: "typeProperty",
format: ["camelCase", "UPPER_CASE", "snake_case"],
leadingUnderscore: "allow",
},
],

"@cspell/spellchecker": [
"warn",
{
autoFix: true,
numSuggestions: 5,
generateSuggestions: true,
checkComments: true,
checkIdentifiers: true,
checkStrings: true,
checkStringTemplates: true,
cspell: {
import: ["./cspell.json"],
},
cspellOptionsRoot: import.meta.url,
},
],
"@cspell/spellchecker": [
"warn",
{
autoFix: true,
numSuggestions: 5,
generateSuggestions: true,
checkComments: true,
checkIdentifiers: true,
checkStrings: true,
checkStringTemplates: true,
cspell: {
import: ["./cspell.json"],
},
},
);
cspellOptionsRoot: import.meta.url,
},
],
},
});
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"@swc/core": "^1.7.26",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"eslint-plugin-import": "2.31.0",
"globals": "^15.11.0",
"http-status": "2.0.0",
"http-status-codes": "2.3.0",
"nest-winston": "^1.9.7",
"npm-run-all": "4.1.5",
"reflect-metadata": "^0.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/health/controllers/health.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Controller, Get, Inject } from "@nestjs/common";
import { HEALTH_ENDPOINT, HEALTH_SERVICE } from "../constants";
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
import { IHealthMessage } from "../interfaces/health-message.interface";
import { HEALTH_ENDPOINT, HEALTH_SERVICE } from "../constants";
import type { IHealthMessage } from "../interfaces/health-message.interface";

@ApiTags("Health")
@Controller(HEALTH_ENDPOINT)
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
"exclude": ["node_modules", "test", "dist", "*.mjs", "**/*spec.ts"]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
"@modules/*": ["src/modules/*"],
}
},
"exclude": ["node_modules", "dist"]
"exclude": ["node_modules", "dist", "*.mjs"]
}

0 comments on commit 28e47d1

Please sign in to comment.