Skip to content

Commit

Permalink
fix: fixing lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dianasavvatina committed Dec 5, 2024
1 parent 8ef09c2 commit d0598bc
Show file tree
Hide file tree
Showing 11 changed files with 6,707 additions and 9,069 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ yarn-error.log*

# vscode
.vscode/settings.json

.yarn
Binary file removed .yarn/install-state.gz
Binary file not shown.
161 changes: 127 additions & 34 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,162 @@ import tsParser from "@typescript-eslint/parser";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import prettierPlugin from "eslint-plugin-prettier";
import importPlugin from "eslint-plugin-import";
import jestPlugin from "eslint-plugin-jest";
import unusedImportsPlugin from "eslint-plugin-unused-imports";
import reactPlugin from "eslint-plugin-react";
// import sortKeysPlugin from "eslint-plugin-sort-keys";

export default {
languageOptions: {
globals: {
NodeJS: true,
jest: true,
global: true,
fetch: true,
},
parser: tsParser,
parserOptions: {
projectService: true,
ecmaVersion: 2020,
sourceType: "module",
project: "./tsconfig.json",
tsconfigRootDir: ".",
},
},
files: ["**/*.ts"],
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["error", {
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}],
"@typescript-eslint/no-non-null-assertion": "warn",
// TypeScript rules
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": [
"warn",
{ allow: ["arrowFunctions"] },
],
"@typescript-eslint/switch-exhaustiveness-check": "warn",
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/no-unnecessary-condition": "warn",
"@typescript-eslint/ban-ts-comment": [
"warn",
{ "ts-ignore": "allow-with-description" },
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/triple-slash-reference": "off",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-misused-promises": [
"warn",
{ checksVoidReturn: { attributes: false } },
],
"@typescript-eslint/no-unused-expressions": [
"warn",
{ allowShortCircuit: true, allowTernary: true, enforceForJSX: true },
],
"@typescript-eslint/consistent-type-imports": [
"error",
{ fixStyle: "inline-type-imports" },
],

// Jest rules
"jest/no-focused-tests": "warn",
"jest/no-identical-title": "warn",
"jest/valid-expect": "warn",
"jest/prefer-to-have-length": "warn",

// Unused imports rule
"unused-imports/no-unused-imports": "warn",

// General rules
"arrow-body-style": ["warn", "as-needed"],
"curly": ["warn", "all"],
"eqeqeq": ["warn", "always"],
"comma-dangle": ["error", "only-multiline"],
"require-await": "error",
"no-undef": "off",
"no-undef": ["error"],
"no-var": ["error"],
"object-curly-spacing": ["error", "always"],
"quotes": ["error", "double", { "allowTemplateLiterals": true }],
"quotes": ["error", "double", { allowTemplateLiterals: true }],
"semi": ["error", "always"],
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-console": ["error", { allow: ["warn"] }],
"no-duplicate-imports": "warn",
"no-restricted-imports": [
"warn",
{
paths: [
{
name: "react",
importNames: ["default"],
message: "use `import { <...> } from 'react'` instead",
},
],
},
],

// Import rules
"import/no-extraneous-dependencies": ["error"],
"import/no-cycle": "warn",
"import/no-self-import": "warn",
"import/no-duplicates": ["warn", { "prefer-inline": true }],
"import/order": [
"warn",
{
"groups": [
"builtin",
"external",
"internal",
["sibling", "parent"],
"index",
"unknown"
groups: [
"builtin", // Built-in imports (come from NodeJS native) go first
"external", // <- External imports
"internal", // <- Absolute imports
["sibling", "parent"], // <- Relative imports, the sibling and parent types they can be mingled together
"index", // <- index imports
"unknown", // <- unknown
],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
alphabetize: {
order: "asc",
caseInsensitive: true,
},
},
],
"sort-imports": [
"warn",
{
ignoreCase: false,
ignoreDeclarationSort: true, // Don't sort import lines, use eslint-plugin-import instead
ignoreMemberSort: false,
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
allowSeparatedGroups: true,
},
],
"sort-keys": [
"warn", // or "error"
"asc", // "asc" for ascending, "desc" for descending
{
caseSensitive: false,
natural: true, // Whether to use natural ordering for numbers (e.g., "a", "10", "2", "b")
minKeys: 2, // Minimum number of keys required in an object for sorting
},
],

// React-specific rules
"react/jsx-curly-brace-presence": ["warn", "never"],
"react/jsx-key": [
"warn",
{
checkFragmentShorthand: true,
checkKeyMustBeforeSpread: true,
warnOnDuplicates: true,
},
],
"import/no-unresolved": "off"
},
ignores: ["dist", "node_modules/*"],
plugins: {
"@typescript-eslint": tsPlugin,
"prettier": prettierPlugin,
"import": importPlugin
prettier: prettierPlugin,
import: importPlugin,
jest: jestPlugin,
"unused-imports": unusedImportsPlugin,
react: reactPlugin,
// "sort-keys": sortKeysPlugin,
},
settings: {
"import/resolver": {
"typescript": {
"project": "./tsconfig.json"
}
}
}
};
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
preset: "ts-jest",
testEnvironment: "node",
setupFiles: ["./test/jest.setup.js"],
setupFiles: ["./src/test/jest.setup.js"],

// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@trili/tezos-provider",
"description": "Tezos Provider for WalletConnect Protocol",
"version": "1.0.9",
"version": "1.0.10",
"author": "Trilitech TriliTech <[email protected]> (https://trili.tech)",
"homepage": "https://trili.tech",
"repository": {
Expand Down Expand Up @@ -36,7 +36,7 @@
"build": "tsup-node",
"test": "jest",
"prettier": "prettier --write .",
"lint": "eslint -c eslint.config.mjs --fix ./src/**/*.ts",
"lint": "eslint -c eslint.config.mjs --fix './src/**/*.{ts,js}'",
"lint:ci": "eslint src/**/*.ts -f json -o lintReport.json || true"
},
"tsup": {
Expand Down Expand Up @@ -89,7 +89,11 @@
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-sort-keys": "^2.3.5",
"eslint-plugin-unused-imports": "^4.1.4",
"install-peerdeps": "^3.0.3",
"jest": "^29.7.0",
"prettier": "^3.3.3",
Expand All @@ -100,6 +104,5 @@
"engines": {
"node": ">=18",
"yarn": ">=1.22"
},
"packageManager": "[email protected]+sha512.1606bef7c84bc7d83b8576063de2fd08f7d69f9939015bed800f9585a002390268ecc777e9feeba7e26e9556aef6beaad4806968db2182ab5dd3e955ab3b9a0b"
}
}
Loading

0 comments on commit d0598bc

Please sign in to comment.