Skip to content
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

Merged
merged 5 commits into from
May 28, 2019

Conversation

FrankHassanabad
Copy link
Contributor

@FrankHassanabad FrankHassanabad commented May 24, 2019

Summary

Low impact linter rules to help catch bugs for back-porting as well as moving into the future. We will slowly turn the warns into errors and fix the errors as we go along. This helps us avoid a "big bang" switch over approach to avoid back-port issues as we are porting bugs aggressively at the beginning.

Added a custom pattern detection rule for determining if the UI is trying to import anything from the server backend since that would cause web-pack front to pull in backend code. Also forbid the use of NodeJS imports on the front end.

Double checked that I was not duplicating rules from:

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials
- [ ] Unit or functional tests were updated or added to match the most common scenarios
- [ ] This was checked for keyboard-only and screenreader accessibility

For maintainers

- [ ] This was checked for breaking API changes and was labeled appropriately
- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately

@elasticmachine
Copy link
Contributor

Pinging @elastic/secops

@FrankHassanabad FrankHassanabad self-assigned this May 24, 2019
@FrankHassanabad FrankHassanabad changed the title Low impact linter rules to start with [SIEM] Low impact linter rules to start with May 24, 2019
@FrankHassanabad FrankHassanabad added the release_note:skip Skip the PR/issue when compiling release notes label May 24, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

.eslintrc.js Outdated Show resolved Hide resolved
// 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'
Copy link
Member

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! :)

// These will be turned on after bug fixes are mostly completed and we can
// run a fix-lint
/*
'import/order': [
Copy link
Member

Choose a reason for hiding this comment

The 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 👍

// 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 }],
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soon for ones such as that one.

'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',
Copy link
Member

@spong spong May 28, 2019

Choose a reason for hiding this comment

The 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 120 errors and it's pretty rampant around the DnD areas within the app.

'react/jsx-fragments': 'error',
'react/jsx-sort-default-props': 'error',
// might be introduced after the other warns are fixed
// 'react/jsx-sort-props': 'error',
Copy link
Member

@spong spong May 28, 2019

Choose a reason for hiding this comment

The 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.

@@ -57,6 +57,7 @@ type KeyUrlState = keyof UrlState;

interface UrlStateProps {
indexPattern: StaticIndexPattern;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@spong spong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked out, ran linter locally and received 17 warnings as expected. Thanks for taking the time to curate these rules and also creating issues for tracking the high-impact rules. I think having the heavy-offenders commented out and turning them on + bugfixing one at a time is a good strategy for getting these enabled and the codebase cleaned up as we move to release.

I've left a few comments, but no changes necessary. Only addition I think would be to create a ticket for tracking the enabling of 'react/jsx-no-bind' as that should result in measurable performance gains with the number of errors that we have for it in our project. Anyway, LGTM! 👍

@FrankHassanabad FrankHassanabad merged commit 1cfad73 into elastic:master May 28, 2019
@FrankHassanabad FrankHassanabad deleted the small-linter branch May 28, 2019 17:14
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request May 28, 2019
## Summary

Low impact linter rules to help catch bugs for back-porting as well as moving into the future. We will slowly turn the warns into errors and fix the errors as we go along. This helps us avoid a "big bang" switch over approach to avoid back-port issues as we are porting bugs aggressively at the beginning.

Added a custom pattern detection rule for determining if the UI is trying to import anything from the server backend since that would cause web-pack front to pull in backend code. Also forbid the use of NodeJS imports on the front end.  

Double checked that I was not duplicating rules from:
* https://github.com/elastic/kibana/blob/master/packages/eslint-config-kibana/typescript.js
* https://github.com/elastic/kibana/blob/master/packages/eslint-config-kibana/javascript.js

### Checklist

Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR.

~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~
~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~
~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~
~- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~
~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~

### For maintainers

~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~
~- [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~
FrankHassanabad added a commit that referenced this pull request May 28, 2019
## Summary

Low impact linter rules to help catch bugs for back-porting as well as moving into the future. We will slowly turn the warns into errors and fix the errors as we go along. This helps us avoid a "big bang" switch over approach to avoid back-port issues as we are porting bugs aggressively at the beginning.

Added a custom pattern detection rule for determining if the UI is trying to import anything from the server backend since that would cause web-pack front to pull in backend code. Also forbid the use of NodeJS imports on the front end.  

Double checked that I was not duplicating rules from:
* https://github.com/elastic/kibana/blob/master/packages/eslint-config-kibana/typescript.js
* https://github.com/elastic/kibana/blob/master/packages/eslint-config-kibana/javascript.js

### Checklist

Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR.

~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~
~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~
~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~
~- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~
~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~

### For maintainers

~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~
~- [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~
jkakavas pushed a commit to jkakavas/kibana that referenced this pull request May 30, 2019
## Summary

Low impact linter rules to help catch bugs for back-porting as well as moving into the future. We will slowly turn the warns into errors and fix the errors as we go along. This helps us avoid a "big bang" switch over approach to avoid back-port issues as we are porting bugs aggressively at the beginning.

Added a custom pattern detection rule for determining if the UI is trying to import anything from the server backend since that would cause web-pack front to pull in backend code. Also forbid the use of NodeJS imports on the front end.  

Double checked that I was not duplicating rules from:
* https://github.com/elastic/kibana/blob/master/packages/eslint-config-kibana/typescript.js
* https://github.com/elastic/kibana/blob/master/packages/eslint-config-kibana/javascript.js

### Checklist

Use ~~strikethroughs~~ to remove checklist items you don't feel are applicable to this PR.

~- [ ] This was checked for cross-browser compatibility, [including a check against IE11](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility)~
~- [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/master/packages/kbn-i18n/README.md)~
~- [ ] [Documentation](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#writing-documentation) was added for features that require explanation or tutorials~
~- [ ] [Unit or functional tests](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#cross-browser-compatibility) were updated or added to match the most common scenarios~
~- [ ] This was checked for [keyboard-only and screenreader accessibility](https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Accessibility#Accessibility_testing_checklist)~

### For maintainers

~- [ ] This was checked for breaking API changes and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~
~- [ ] This includes a feature addition or change that requires a release note and was [labeled appropriately](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md#release-notes-process)~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:SIEM v7.3.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants