-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SIEM] Low impact linter rules to start with #37137
Changes from all commits
5f4171c
53d0b54
6041cb6
1b99d45
5930455
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,10 +400,185 @@ module.exports = { | |
* SIEM overrides | ||
*/ | ||
{ | ||
files: ['x-pack/plugins/siem/**/*.ts'], | ||
// front end typescript and javascript files only | ||
files: ['x-pack/plugins/siem/public/**/*.{js,ts,tsx}'], | ||
rules: { | ||
'import/no-nodejs-modules': 'error', | ||
'no-restricted-imports': [ | ||
'error', | ||
{ | ||
// prevents UI code from importing server side code and then webpack including it when doing builds | ||
patterns: ['**/server/*'], | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
// typescript only for front and back end | ||
files: ['x-pack/plugins/siem/**/*.{ts,tsx}'], | ||
rules: { | ||
// This will be turned on after bug fixes are complete | ||
// '@typescript-eslint/explicit-member-accessibility': 'warn', | ||
'@typescript-eslint/no-this-alias': 'error', | ||
'@typescript-eslint/no-explicit-any': 'error', | ||
'import/order': 'error', | ||
'@typescript-eslint/no-useless-constructor': 'error', | ||
// This will be turned on after bug fixes are complete | ||
// '@typescript-eslint/no-object-literal-type-assertion': 'warn', | ||
'@typescript-eslint/unified-signatures': 'error', | ||
|
||
// eventually we want this to be a warn and then an error since this is a recommended linter rule | ||
// for now, keeping it commented out to avoid too much IDE noise until the other linter issues | ||
// are fixed in the next release or two | ||
// '@typescript-eslint/explicit-function-return-type': 'warn', | ||
|
||
// these rules cannot be turned on and tested at the moment until this issue is resolved: | ||
// https://github.com/prettier/prettier-eslint/issues/201 | ||
// '@typescript-eslint/await-thenable': 'error', | ||
// '@typescript-eslint/no-non-null-assertion': 'error' | ||
// '@typescript-eslint/no-unnecessary-type-assertion': 'error', | ||
// '@typescript-eslint/no-unused-vars': 'error', | ||
// '@typescript-eslint/prefer-includes': 'error', | ||
// '@typescript-eslint/prefer-string-starts-ends-with': 'error', | ||
// '@typescript-eslint/promise-function-async': 'error', | ||
// '@typescript-eslint/prefer-regexp-exec': 'error', | ||
// '@typescript-eslint/promise-function-async': 'error', | ||
// '@typescript-eslint/require-array-sort-compare': 'error', | ||
// '@typescript-eslint/restrict-plus-operands': 'error', | ||
// '@typescript-eslint/unbound-method': 'error', | ||
}, | ||
}, | ||
{ | ||
// typescript and javascript for front and back end | ||
files: ['x-pack/plugins/siem/**/*.{js,ts,tsx}'], | ||
plugins: ['react'], | ||
rules: { | ||
'accessor-pairs': 'error', | ||
'array-callback-return': 'error', | ||
'no-array-constructor': 'error', | ||
// This will be turned on after bug fixes are mostly completed | ||
// 'arrow-body-style': ['warn', 'as-needed'], | ||
complexity: 'warn', | ||
// This will be turned on after bug fixes are mostly completed | ||
// 'consistent-return': 'warn', | ||
// This will be turned on after bug fixes are mostly completed | ||
// 'func-style': ['warn', 'expression'], | ||
// These will be turned on after bug fixes are mostly completed and we can | ||
// run a fix-lint | ||
/* | ||
'import/order': [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excited to get this back in as well. This is going to be a big change though, so I think holding off for now is 👍 |
||
'warn', | ||
{ | ||
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
*/ | ||
'no-bitwise': 'error', | ||
'no-continue': 'error', | ||
'no-dupe-keys': 'error', | ||
'no-duplicate-case': 'error', | ||
// This will be turned on after bug fixes are mostly completed | ||
// 'no-duplicate-imports': 'warn', | ||
'no-empty-character-class': 'error', | ||
'no-empty-pattern': 'error', | ||
'no-ex-assign': 'error', | ||
'no-extend-native': 'error', | ||
'no-extra-bind': 'error', | ||
'no-extra-boolean-cast': 'error', | ||
'no-extra-label': 'error', | ||
'no-floating-decimal': 'error', | ||
'no-func-assign': 'error', | ||
'no-implicit-globals': 'error', | ||
'no-implied-eval': 'error', | ||
'no-invalid-regexp': 'error', | ||
'no-inner-declarations': 'error', | ||
'no-lone-blocks': 'error', | ||
'no-multi-assign': 'error', | ||
'no-misleading-character-class': 'error', | ||
'no-new-symbol': 'error', | ||
'no-obj-calls': 'error', | ||
// This will be turned on after bug fixes are mostly complete | ||
// 'no-param-reassign': 'warn', | ||
'no-process-exit': 'error', | ||
'no-prototype-builtins': 'error', | ||
// This will be turned on after bug fixes are mostly complete | ||
// 'no-return-await': 'warn', | ||
'no-self-compare': 'error', | ||
'no-shadow-restricted-names': 'error', | ||
'no-sparse-arrays': 'error', | ||
'no-this-before-super': 'error', | ||
// This will be turned on after bug fixes are mostly complete | ||
// 'no-undef': 'warn', | ||
'no-unreachable': 'error', | ||
'no-unsafe-finally': 'error', | ||
'no-useless-call': 'error', | ||
// This will be turned on after bug fixes are mostly complete | ||
// 'no-useless-catch': 'warn', | ||
'no-useless-concat': 'error', | ||
'no-useless-computed-key': 'error', | ||
// This will be turned on after bug fixes are mostly complete | ||
// 'no-useless-escape': 'warn', | ||
'no-useless-rename': 'error', | ||
// This will be turned on after bug fixes are mostly complete | ||
// 'no-useless-return': 'warn', | ||
// This will be turned on after bug fixers are mostly complete | ||
// 'no-void': 'warn', | ||
'one-var-declaration-per-line': 'error', | ||
'prefer-object-spread': 'error', | ||
'prefer-promise-reject-errors': 'error', | ||
'prefer-rest-params': 'error', | ||
'prefer-spread': 'error', | ||
// This style will be turned on after most bugs are fixed | ||
// 'prefer-template': 'warn', | ||
// This style will be turned on after most bugs are fixed | ||
// quotes: ['warn', 'single', { avoidEscape: true }], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There've been plenty of PR comments for this one. ++ for this rule. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Soon for ones such as that one. |
||
'react/boolean-prop-naming': 'error', | ||
'react/button-has-type': 'error', | ||
'react/forbid-dom-props': 'error', | ||
// This will go from warn to error when this is fixed: | ||
// https://github.com/elastic/ingest-dev/issues/468 | ||
'react/no-access-state-in-setstate': 'warn', | ||
// This style will be turned on after most bugs are fixed | ||
// 'react/no-children-prop': 'warn', | ||
'react/no-danger-with-children': 'error', | ||
'react/no-deprecated': 'error', | ||
'react/no-did-mount-set-state': 'error', | ||
// This will go from warn to error when this is fixed: | ||
// https://github.com/elastic/ingest-dev/issues/468 | ||
'react/no-did-update-set-state': 'warn', | ||
'react/no-direct-mutation-state': 'error', | ||
'react/no-find-dom-node': 'error', | ||
'react/no-redundant-should-component-update': 'error', | ||
'react/no-render-return-value': 'error', | ||
'react/no-typos': 'error', | ||
'react/no-string-refs': 'error', | ||
'react/no-this-in-sfc': 'error', | ||
// This can go from warn to error once this is fixed | ||
// https://github.com/elastic/ingest-dev/issues/467 | ||
'react/no-unescaped-entities': 'warn', | ||
'react/no-unsafe': 'error', | ||
'react/no-unused-prop-types': 'error', | ||
'react/no-unused-state': 'error', | ||
// will introduced after the other warns are fixed | ||
// 'react/sort-comp': 'error', | ||
'react/void-dom-elements-no-children': 'error', | ||
'react/jsx-boolean-value': ['error', 'warn'], | ||
// will introduced after the other warns are fixed | ||
// 'react/jsx-no-bind': 'error', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's a strong argument for getting this rule on sooner than later from a perf standpoint. Should we open an issue for tracking to raise visibility? Turning it on showed |
||
'react/jsx-no-comment-textnodes': 'error', | ||
// will be introduced to fix missing i18n keys | ||
// 'react/jsx-no-literals': 'warn', | ||
'react/jsx-no-target-blank': 'error', | ||
'react/jsx-fragments': 'error', | ||
'react/jsx-sort-default-props': 'error', | ||
// might be introduced after the other warns are fixed | ||
// 'react/jsx-sort-props': 'error', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the existing patterns in the codebase, I think the team would be happy to have this enabled, albeit with the callbacksLast and reservedFirst options enabled as well. |
||
'react/jsx-tag-spacing': 'error', | ||
'require-atomic-updates': 'error', | ||
'rest-spread-spacing': ['error', 'never'], | ||
'symbol-description': 'error', | ||
'template-curly-spacing': 'error', | ||
'vars-on-top': 'error', | ||
}, | ||
}, | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ type KeyUrlState = keyof UrlState; | |
|
||
interface UrlStateProps { | ||
indexPattern: StaticIndexPattern; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good news -- I think this one is getting cleaned up here: https://github.com/elastic/kibana/pull/36954/files#diff-8fd82466ad8233a23f8deedd497d9058R58 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep |
||
mapToUrlState?: (value: any) => UrlState; | ||
onChange?: (urlState: UrlState, previousUrlState: UrlState) => void; | ||
onInitialize?: (urlState: UrlState) => void; | ||
|
@@ -394,6 +395,7 @@ export const UrlStateContainer = connect( | |
// @ts-ignore | ||
)(UrlStateComponents); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const decodeRisonUrlState = (value: string | undefined): RisonValue | any | undefined => { | ||
try { | ||
return value ? decode(value) : undefined; | ||
|
@@ -405,6 +407,7 @@ export const decodeRisonUrlState = (value: string | undefined): RisonValue | any | |
} | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const encodeRisonUrlState = (state: any) => encode(state); | ||
|
||
export const getQueryStringFromLocation = (location: Location) => location.search.substring(1); | ||
|
@@ -414,6 +417,7 @@ export const getParamFromQueryString = (queryString: string, key: string): strin | |
return Array.isArray(queryParam) ? queryParam[0] : queryParam; | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const replaceStateKeyInQueryString = <UrlState extends any>( | ||
stateKey: string, | ||
urlState: UrlState | undefined | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking forward to this one
!
:)