Commit graph

22 commits

Author SHA1 Message Date
Wylie Conlon 87ee9c2a9b
Warn in Typescript when using Array.flat() or .flatMap() without polyfill (#37558)
* Warn in Typescript when using Array.flat() or .flatMap() without polyfill

* Update ecma version provided to babel in eslint

* Update per review comments
2019-06-03 13:52:38 -04:00
Tiago Costa ed795d28ee
Migrate from tslint (#33826)
* chore(NA): remove tslint dependencies, configs and enable eslint typescript parser.

* fix(NA): apply recommend eslint typescript rule.s

* chore(NA): upgrade eslint package versions.

* chore(NA): split javascript eslint config in an override section.

* chore(NA): split all eslint configs with overrides.

* chore(NA): remove missing console.log.

* chore(NA): change eslint splits and overrides order.

* chore(NA): replace tslint disable comments with eslint ones.

* chore(NA): solve eslint typescript errors for elastic/kibana-custom/no-default-export

* chore(NA): fixed multiple eslint typescript rule failures.

* chore(NA): add tarfet folder to the eslint ignore.

* chore(NA): apply prettier rule to ts type file.

* chore(NA): remove last mentions to tslint

* chore(NA): add old defined rules

* chore(NA): missing port rules website

* chore(na): ordered rules

* chore(NA): solved eslint typescript problems.

* chore(NA): fix spaced comment problems.

* chore(NA): fix some more eslint typescript rules: import/order no-empty-interface

* chore(NA): fix last rules and comment out what are the ones still failing.

* chore(NA): comment out camelcase rule.

* chore(NA): regenerate kbn pm dist.

* chore(NA): updated snapshots.

* chore(NA): updated snapshots.

* chore(NA): disabled sort-keys rule.

* chore(NA): remove rule prefer-arrow/prefer-arrow-functions.

* chore(NA): fix for @typescript-eslint/no-var-requires rule.

* chore(NA): fixes for @typescript-eslint/camelcase rule.

* chore(NA): fix typo on eslint config kibana typescript.

Co-Authored-By: mistic <tiagoffcc@hotmail.com>

* chore(NA): remove legacy note after the intellij upgrade to 2019.1

* fix(NA): import order plugin.

* chore(NA): fix ts ignore positions after auto fix.

* fix(NA): performance issue with typescript eslint.

* refact(NA): eslint configs organization.

* chore(NA): apply resticted paths to ts files too.

* chore(NA): split comment from eslint ignore.
2019-04-05 17:45:23 +01:00
CJ Cenizal 33fa8c0c6b
Add eslint rule for checking React Hooks best practices. (#33901)
* Rename Console's useResizeChecker to applyResizeCheckerToEditors, to bypass greedy react-hooks lint rule.
2019-03-26 20:18:14 -07:00
Joe Fleming 228d69c708
Fix: set react version to string, not semver object (#33079)
## Summary

While working on a plugin that was just using the Kibana eslint config, I saw a stream of these messages:

> Warning: React version specified in eslint-plugin-react-settings must be a string; got “object”

Looking into our eslint config, I noticed we're using `semver.coerce` to get the version from the `package.json` file in Kibana. This looked right, except that method actually returns an object:

```js
const ver = semver.coerce('^16.8.0');
console.log(ver);
```

That produces:

```
SemVer {
  options: { loose: false, includePrerelease: false },
  loose: false,
  raw: '16.8.0',
  major: 16,
  minor: 8,
  patch: 0,
  prerelease: [],
  build: [],
  version: '16.8.0' }
```

The [semver package](https://www.npmjs.com/package/semver) includes some examples where they wrap that value in `semver.valid`, which produces a string and fixes the warning.

```js
const ver = semver.valid(semver.coerce('^16.8.0'));
console.log(ver); // outputs 16.8.0
```

### So why don't we see this warning in Kibana?

I'm not sure, but I suspect it's because it's a console warning and our tooling prevents that output from showing up. 

This change stops the warning output when you run eslint in my plugin though. 

UPDATE: After some more digging, it looks like it's related to the version override in Kibana's eslintrc. Removing the override stops the linter from running, without the changes in this PR.
2019-03-13 10:50:01 -07:00
Spencer 369bef316a
[eslint] require final newline (#32265)
We have had `insert_final_newline = true` in our `.editorconfig` file since April 2015, but never validated it with eslint. I'm a little tired of extra changes showing up in PRs because some people use editors which respect the `.editorconfig` file and some don't, so I figured we might want to enable the rule in eslint so that the can be autofixed.

Votes requested please :)
2019-02-28 18:01:29 -08:00
Larry Gregory 22ba11eb52
Prevents dynamic import/require statements (#27515)
## Summary

This PR enables the `import/no-dynamic-require` eslint rule, which requires that all require/import statements be statically defined.

This mitigates certain attack vectors, such as those which enabled [`ESA-2018-18`](https://www.elastic.co/community/security)/[`CVE-2018-17246`](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-17246)
2018-12-21 11:15:20 -05:00
Bhavya RM 7e2e450486
Adding label-has-associated-control to jsx-a11y lint rules and associated UI fixes 2018-12-12 10:04:15 -05:00
Spencer 707a0359c8
[kbn-plugin-generator] add eslint-plugin-jsx-a11y to plugin devDeps (#25606)
* [kbn-plugin-generator] add eslint-plugin-jsx-a11y to plugin devDeps, specify react version in config

* [eslint/react] use semver package to coerce version range

* fix semicolons
2018-11-15 15:40:01 -08:00
Bhavya RM 4c0a5e5a67
Adding jsxa11y into eslint rules (#23932) 2018-11-01 12:47:16 -04:00
Tim Sullivan f2e4282aad
[ESLint] Turn off no-multi-str rule in eslint config (#22525)
* remove inline rule disabling comments

* turn off no-multi-str
2018-08-31 09:55:23 -07:00
Josh Soref 2b27fb1c5f Fix misspellings (#19981) 2018-06-26 20:17:41 -07:00
Tim Roes f579d2299f
Update React to 16.3 (#18768)
* Update React to 16.3

* Switch off specific eslint rules

* Update enzyme snapshots

* Incorporate PR feedback
2018-05-14 14:05:17 +02:00
Larry Gregory d9d9fb22fb
Disallow use of "dangerouslySetInnerHTML" on React components (#17759)
Disallows use of "dangerouslySetInnerHTML" on React components, except where explicitly whitelisted
2018-04-20 14:22:10 -04:00
Court Ewing 271a941621
lint: error on innerHTML and family (#16477)
* lint for innerHTML and family

Browser apis like innerHTML and document.write are dangerous when used
incorrectly, so we should not be using them unless we explicitly opt-out
of the linting rule on a case by case basis.

* add no-unsanitized to eslint peerDependencies
2018-02-04 08:38:37 -05:00
Spencer 28663f6f8e
[eslint-config-kibana] expand list of restricted globals (#15798) 2018-01-03 10:52:30 -07:00
CJ Cenizal 05cbb92965 [eslint-config-kibana] Apply AirBnB spacing rules (#14522)
* Add AirBnB key-spacing rule.
* Add AirBnB comma-spacing rule.
2017-10-25 15:08:05 -07:00
Spencer bd53cc6370 Eslint/remove last amd modules (#14282)
* [timelion] remove last remaining amd modules

* [eslint-config-kibana] remove env.amd
2017-10-10 16:10:56 +02:00
Kim Joar Bekkelund 6a2bb74407 Use Object spread instead of Object.assign where it makes sense (#13903)
* Prefer Object spread

* Add eslint rules for Object spread

* no slice
2017-10-10 14:50:56 +02:00
CJ Cenizal b670baeeec Add AirBnB linting rules for React best practices. Bump to v0.10.0. (#13259) 2017-08-03 08:18:08 -07:00
Felix Stürmer 3884d38913 [eslint-config-kibana] Add jest plugin and settings (#13090) 2017-07-28 14:00:19 +02:00
CJ Cenizal b3ffd99542 Add linting rules for formatting JSX. (#12810)
* Add linting rules for formatting JSX.
* Bump eslint config version to 0.8.0.
2017-07-26 08:51:15 -07:00
Kim Joar Bekkelund bdaf8485b0 Move eslint-config-kibana into core (#12725)
* Initial commit

* added actual config

* version 0.0.1

* version 0.0.2

* [no-const-assign] Disallow assignment to const

http://eslint.org/docs/rules/no-const-assign

* [no-redeclare] Disallow redeclaring variables

http://eslint.org/docs/rules/no-redeclare

* version 0.0.3

* [no-unused-vars]: Disallow declaration of variables that are not used in the code.

* Bump to 0.1.0.

* upgrade deps in preperation for babel6 transition

* 0.2.0-alpha1

* use yaml for readability

* 0.2.0

* update/pin peed dependency versions

* 0.2.1

* [quotes] allow template literals

This allows eslint to validate this rule from the styleguide: https://github.com/elastic/kibana/blob/master/style_guides/js_style_guide.md#use-template-strings-to-avoid-escaping-single-quotes

* 0.2.2

* add object-curly-spacing and no-global-assign rules

* sort .eslintrc.yaml rules

* 0.3.0

* add basic react support

* 0.4.0

* Disallow using 'context' in tests

* 0.5.0

* move from .eslintrc.yaml to .eslintrc.js without .json generation (#6)

* Implement import plugin (#7)

* update deps

* include eslint-plugin-import

* Dereference import config (#8)

* reorganize existing rules into groups

* defreference eslint-plugin-import "recommended" config

Based on ea9c92c732/config/recommended.js

* 0.6.0

* set environment info for import rule

* 0.6.1

* update peerDependencies

* 0.7.0

* Move eslint-config-kibana into packages directory
2017-07-25 10:02:14 +02:00