Skip to content

Commit

Permalink
feat: [M3-8741] - Add linter rules for common pr feedback points (#11258
Browse files Browse the repository at this point in the history
)

* Add linter rules for common pr feedback points

* Add linter rules in ui package

* Add linter rules in api-v4

* Update eslint rules in validation pkg

* refactor rules and add perfectionist rules to ui package

* Added changeset: Linter rules for common pr feedback points

* Added changeset: Linter rules for common pr feedback points

* Added changeset: Linter rules for common pr feedback points

* Remove existing broken camelCase rule
  • Loading branch information
pmakode-akamai authored Nov 21, 2024
1 parent 18b2bf9 commit 654d24c
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 72 deletions.
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-11258-added-1731996671316.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Added
---

Linter rules for common pr feedback points ([#11258](https://github.com/linode/manager/pull/11258))
28 changes: 7 additions & 21 deletions packages/api-v4/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
{
"ignorePatterns": [
"node_modules",
"lib",
"index.js",
"!.eslintrc.js"
],
"ignorePatterns": ["node_modules", "lib", "index.js", "!.eslintrc.js"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"warnOnUnsupportedTypeScriptVersion": true
},
"plugins": [
"@typescript-eslint",
"sonarjs",
"prettier"
],
"plugins": ["@typescript-eslint", "sonarjs", "prettier"],
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
Expand All @@ -38,21 +29,17 @@
"array-callback-return": "error",
"no-invalid-this": "off",
"no-new-wrappers": "error",
"no-restricted-imports": [
"error",
"rxjs"
],
"no-restricted-imports": ["error", "rxjs"],
"no-console": "error",
"no-undef-init": "off",
"radix": "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/interface-name-prefix": "off",
"sonarjs/cognitive-complexity": "warn",
Expand All @@ -62,6 +49,7 @@
"sonarjs/no-redundant-jump": "warn",
"sonarjs/no-small-switch": "warn",
"no-multiple-empty-lines": "error",
"camelcase": ["warn", { "properties": "always" }],
"curly": "warn",
"sort-keys": "off",
"comma-dangle": "off",
Expand All @@ -74,9 +62,7 @@
},
"overrides": [
{
"files": [
"*ts"
],
"files": ["*ts"],
"rules": {
"@typescript-eslint/ban-types": [
"warn",
Expand All @@ -97,4 +83,4 @@
}
}
]
}
}
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11258-added-1731996833931.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

Linter rules for common pr feedback points ([#11258](https://github.com/linode/manager/pull/11258))
5 changes: 3 additions & 2 deletions packages/manager/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,12 @@ module.exports = {
rules: {
'@linode/cloud-manager/deprecate-formik': 'warn',
'@linode/cloud-manager/no-custom-fontWeight': 'error',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-empty-interface': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-namespace': 'warn',
// this would disallow usage of ! postfix operator on non null types
Expand All @@ -175,6 +174,7 @@ module.exports = {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'array-callback-return': 'error',
camelcase: ['warn', { properties: 'always' }],
'comma-dangle': 'off', // Prettier and TS both handle and check for this one
// radix: Codacy considers it as an error, i put it here to fix it before push
curly: 'warn',
Expand Down Expand Up @@ -274,6 +274,7 @@ module.exports = {
'react/no-unescaped-entities': 'warn',
// requires the definition of proptypes for react components
'react/prop-types': 'off',
'react/self-closing-comp': 'warn',
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react-refresh/only-export-components': 'warn',
Expand Down
5 changes: 5 additions & 0 deletions packages/ui/.changeset/pr-11258-added-1731997009185.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/ui": Added
---

Linter rules for common pr feedback points ([#11258](https://github.com/linode/manager/pull/11258))
100 changes: 69 additions & 31 deletions packages/ui/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"ignorePatterns": [
"node_modules",
"lib",
"index.js",
"!.eslintrc.js"
],
"ignorePatterns": ["node_modules", "lib", "index.js", "!.eslintrc.js"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"warnOnUnsupportedTypeScriptVersion": true
},
"plugins": [
"@typescript-eslint",
"react",
"sonarjs",
"prettier",
"@linode/eslint-plugin-cloud-manager"
Expand All @@ -20,9 +16,24 @@
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:sonarjs/recommended",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
"plugin:perfectionist/recommended-natural"
],
"rules": {
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/interface-name-prefix": "off",
"array-callback-return": "error",
"camelcase": ["warn", { "properties": "always" }],
"comma-dangle": "off",
"curly": "warn",
"no-unused-vars": [
"warn",
{
Expand All @@ -36,40 +47,67 @@
"no-throw-literal": "warn",
"no-loop-func": "error",
"no-await-in-loop": "error",
"array-callback-return": "error",
"no-invalid-this": "off",
"no-new-wrappers": "error",
"no-restricted-imports": [
"error",
"rxjs"
],
"no-restricted-imports": ["error", "rxjs"],
"no-console": "error",
"no-undef-init": "off",
"no-multiple-empty-lines": "error",
"no-trailing-spaces": "warn",
"no-mixed-requires": "warn",
"object-shorthand": "warn",
// Perfectionist
"perfectionist/sort-array-includes": "warn",
"perfectionist/sort-classes": "warn",
"perfectionist/sort-enums": "warn",
"perfectionist/sort-exports": "warn",
"perfectionist/sort-imports": [
"warn",
{
"custom-groups": {
"type": {
"react": ["react", "react-*"],
"src": ["src*"]
},
"value": {
"src": ["src/**/*"]
}
},
"groups": [
["builtin", "libraries", "external"],
["src", "internal"],
["parent", "sibling", "index"],
"object",
"unknown",
["type", "internal-type", "parent-type", "sibling-type", "index-type"]
],
"newlines-between": "always"
}
],
"perfectionist/sort-interfaces": "warn",
"perfectionist/sort-jsx-props": "warn",
"perfectionist/sort-map-elements": "warn",
"perfectionist/sort-named-exports": "warn",
"perfectionist/sort-named-imports": "warn",
"perfectionist/sort-object-types": "warn",
"perfectionist/sort-objects": "warn",
"perfectionist/sort-union-types": "warn",
// prettier
"prettier/prettier": "warn",
// radix
"radix": "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/interface-name-prefix": "off",
// react and jsx specific rules
"react/self-closing-comp": "warn",
"react/jsx-no-useless-fragment": "warn",
"react/no-unescaped-entities": "warn",
// sonar
"sonarjs/cognitive-complexity": "off",
"sonarjs/no-duplicate-string": "warn",
"sonarjs/prefer-immediate-return": "warn",
"sonarjs/no-identical-functions": "warn",
"sonarjs/no-redundant-jump": "warn",
"sonarjs/no-small-switch": "warn",
"no-multiple-empty-lines": "error",
"curly": "warn",
"sort-keys": "off",
"comma-dangle": "off",
"no-trailing-spaces": "warn",
"no-mixed-requires": "warn",
"spaced-comment": "warn",
"object-shorthand": "warn",
"prettier/prettier": "warn"
"spaced-comment": "warn"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/validation": Added
---

Linter rules for common pr feedback points ([#11258](https://github.com/linode/manager/pull/11258))
23 changes: 5 additions & 18 deletions packages/validation/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
{
"ignorePatterns": [
"node_modules",
"lib",
"index.js",
"!.eslintrc.js"
],
"ignorePatterns": ["node_modules", "lib", "index.js", "!.eslintrc.js"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"warnOnUnsupportedTypeScriptVersion": true
},
"plugins": [
"@typescript-eslint",
"sonarjs",
"prettier"
],
"plugins": ["@typescript-eslint", "sonarjs", "prettier"],
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
Expand All @@ -38,21 +29,17 @@
"array-callback-return": "error",
"no-invalid-this": "off",
"no-new-wrappers": "error",
"no-restricted-imports": [
"error",
"rxjs"
],
"no-restricted-imports": ["error", "rxjs"],
"no-console": "error",
"no-undef-init": "off",
"radix": "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/interface-name-prefix": "off",
"sonarjs/cognitive-complexity": "warn",
Expand All @@ -71,4 +58,4 @@
"object-shorthand": "warn",
"prettier/prettier": "warn"
}
}
}

0 comments on commit 654d24c

Please sign in to comment.