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

Add @elastic/safer-lodash-set as an alternative to lodash.set #67452

Merged
merged 63 commits into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
05d9664
Initial inline of @elastic/safer-lodash-set
watson May 26, 2020
fafb173
Comply with Kibana monorepo rules andi styling
watson May 26, 2020
8358e2b
Refactor all use of lodash.set to @elastic/safer-lodash-set
watson May 27, 2020
f4f7eeb
Add lodash/fp to ESLint blacklist
watson May 27, 2020
4d6d865
Remove standardjs badge from README.md
watson May 27, 2020
d41353c
Rename @elastic/safer-lodash-set to @kbn/safer-lodash-set
watson May 27, 2020
3619c8e
For now we don't want to publish this module
watson May 27, 2020
49d8875
Merge branch 'master' into safer-lodash-set
watson Jun 10, 2020
e68344a
Remove duplicate entry in x-pack/package.json
watson Jun 10, 2020
8dd6a76
Merge branch 'master' into safer-lodash-set
watson Jun 25, 2020
8e54d46
Rename @kbn namespace back to @elastic
watson Jun 25, 2020
48ec297
Add TypeScript tests
watson Jun 25, 2020
3415afd
Merge branch 'master' into safer-lodash-set
watson Jun 29, 2020
c1bc23e
Fix new wrong uses of Lodash from master
watson Jun 29, 2020
5eb4809
Update licenses
watson Jun 30, 2020
eddf9ff
Expose TypeScript types in package.json
watson Jun 30, 2020
2e1b518
Merge branch 'master' into safer-lodash-set
watson Jun 30, 2020
a55d85c
Add license header to script files
watson Jun 30, 2020
c12b6bd
Run package tests as part of CI
watson Jul 1, 2020
899bea0
Merge branch 'master' into safer-lodash-set
watson Jul 1, 2020
17719ff
Ups
watson Jul 1, 2020
f577950
Merge branch 'master' into safer-lodash-set
watson Jul 2, 2020
20d7b10
Allow ESLint to test the lodash folder
watson Jul 2, 2020
524bf02
Re-adding package to x-pack package.json
watson Jul 2, 2020
f2929cb
ups
watson Jul 2, 2020
2d0eefb
Merge branch 'master' into safer-lodash-set
watson Jul 3, 2020
3d21a0d
Remove unchanged lodash files and rely on peerDependency
watson Jul 4, 2020
b403435
Add support for lodash/fp
watson Jul 4, 2020
e3c12d5
Merge branch 'master' into safer-lodash-set
watson Jul 4, 2020
dd254fb
Use @elastic/safer-lodash-set/fp version instead of lodash/fp
watson Jul 4, 2020
5375150
Apply suggestions from code review
watson Jul 7, 2020
7f93093
Merge branch 'master' into safer-lodash-set
watson Jul 7, 2020
88d14ea
Fix typos
watson Jul 7, 2020
4cc8d30
Use bash instead of sh for scripts
watson Jul 7, 2020
c85b8f7
Actually run the package tests
watson Jul 7, 2020
664e8b2
Ensure linebreaks are rendered correctly
watson Jul 7, 2020
86c15a2
Throw if prototype is set on arrow-functions
watson Jul 7, 2020
2af8ae0
Use lodash.isFunction instead of typeof
watson Jul 7, 2020
2ac1333
Fix typo in LICENSE
watson Jul 7, 2020
7b1c024
Fix typo in comment
watson Jul 7, 2020
cf11b62
Fix .npmignore
watson Jul 7, 2020
e0d54fa
Add tsconfig.json
watson Jul 7, 2020
2621244
Use tape instead of assert
watson Jul 8, 2020
b942bae
Fix tsd issue related to new tsconfig.json file
watson Jul 8, 2020
747c69e
Remove private field from package.json
watson Jul 8, 2020
adbaee6
forgot with tape
watson Jul 8, 2020
2f31347
Bump tsd
watson Jul 8, 2020
c3b4351
Fix bug with fp api
watson Jul 8, 2020
cea10a8
Add fp TypeScript types
watson Jul 8, 2020
54239dd
Update saved state
watson Jul 8, 2020
ccf2b4d
Fix README.md to reflect reality
watson Jul 8, 2020
6d4da53
Extend tsconfig.json from root
watson Jul 9, 2020
dd35300
Merge branch 'master' into safer-lodash-set
watson Jul 9, 2020
34316df
Merge branch 'master' into safer-lodash-set
watson Jul 9, 2020
a33c7ed
Whitelist files for casing
watson Jul 9, 2020
93ff996
Merge branch 'master' into safer-lodash-set
elasticmachine Jul 9, 2020
7dd9e3e
Merge branch 'master' into safer-lodash-set
elasticmachine Jul 10, 2020
fb7c63d
Merge branch 'master' into pr-67452-safer
azasypkin Jul 14, 2020
41c6acf
Disable ESLint `var` warning to be closer to the lodash source code.
azasypkin Jul 14, 2020
daf8eb0
Merge branch 'master' into pr-67452-safer
azasypkin Jul 14, 2020
9b99a23
Merge branch 'master' into pr-67452-safer
azasypkin Jul 15, 2020
415fdd2
Merge branch 'master' into safer-lodash-set
elasticmachine Jul 15, 2020
1b4d708
Update yarn.lock.
azasypkin Jul 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 227 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,31 @@ const ELASTIC_LICENSE_HEADER = `
*/
`;

const SAFER_LODASH_SET_HEADER = `
/*
* Elasticsearch B.V licenses this file to you under the MIT License.
* See \`packages/elastic-safer-lodash-set/LICENSE\` more information.
*/
`;

const SAFER_LODASH_SET_LODASH_HEADER = `
/*
* This file is forked from the lodash project (https://lodash.com/),
* and may include modifications made by Elasticsearch B.V.
* Elasticsearch B.V. licenses this file to you under the MIT License.
* See \`packages/elastic-safer-lodash-set/LICENSE\` more information.
*/
`;

const SAFER_LODASH_SET_DEFINITLYTYPED_HEADER = `
/*
* This file is forked from the DefinitlyTyped project (https://github.com/DefinitelyTyped/DefinitelyTyped),
watson marked this conversation as resolved.
Show resolved Hide resolved
* and may include modifications made by Elasticsearch B.V.
* Elasticsearch B.V. licenses this file to you under the MIT License.
* See \`packages/elastic-safer-lodash-set/LICENSE\` more information.
*/
`;

const allMochaRulesOff = {};
Object.keys(require('eslint-plugin-mocha').rules).forEach((k) => {
allMochaRulesOff['mocha/' + k] = 'off';
Expand Down Expand Up @@ -143,7 +168,12 @@ module.exports = {
'@kbn/eslint/disallow-license-headers': [
'error',
{
licenses: [ELASTIC_LICENSE_HEADER],
licenses: [
ELASTIC_LICENSE_HEADER,
SAFER_LODASH_SET_HEADER,
SAFER_LODASH_SET_LODASH_HEADER,
SAFER_LODASH_SET_DEFINITLYTYPED_HEADER,
],
},
],
},
Expand Down Expand Up @@ -174,7 +204,82 @@ module.exports = {
'@kbn/eslint/disallow-license-headers': [
'error',
{
licenses: [APACHE_2_0_LICENSE_HEADER],
licenses: [
APACHE_2_0_LICENSE_HEADER,
SAFER_LODASH_SET_HEADER,
SAFER_LODASH_SET_LODASH_HEADER,
SAFER_LODASH_SET_DEFINITLYTYPED_HEADER,
],
},
],
},
},

/**
* safer-lodash-set package requires special license headers
*/
{
files: ['packages/elastic-safer-lodash-set/**/*.{js,mjs,ts,tsx}'],
rules: {
'@kbn/eslint/require-license-header': [
'error',
{
license: SAFER_LODASH_SET_LODASH_HEADER,
},
],
'@kbn/eslint/disallow-license-headers': [
'error',
{
licenses: [
ELASTIC_LICENSE_HEADER,
APACHE_2_0_LICENSE_HEADER,
SAFER_LODASH_SET_HEADER,
SAFER_LODASH_SET_DEFINITLYTYPED_HEADER,
],
},
],
},
},
{
files: ['packages/elastic-safer-lodash-set/{fp,test}/*.{js,mjs,ts,tsx}'],
rules: {
'@kbn/eslint/require-license-header': [
'error',
{
license: SAFER_LODASH_SET_HEADER,
},
],
'@kbn/eslint/disallow-license-headers': [
'error',
{
licenses: [
ELASTIC_LICENSE_HEADER,
APACHE_2_0_LICENSE_HEADER,
SAFER_LODASH_SET_LODASH_HEADER,
SAFER_LODASH_SET_DEFINITLYTYPED_HEADER,
],
},
],
},
},
{
files: ['packages/elastic-safer-lodash-set/*.d.ts'],
rules: {
'@kbn/eslint/require-license-header': [
'error',
{
license: SAFER_LODASH_SET_DEFINITLYTYPED_HEADER,
},
],
'@kbn/eslint/disallow-license-headers': [
'error',
{
licenses: [
ELASTIC_LICENSE_HEADER,
APACHE_2_0_LICENSE_HEADER,
SAFER_LODASH_SET_HEADER,
SAFER_LODASH_SET_LODASH_HEADER,
],
},
],
},
Expand Down Expand Up @@ -544,6 +649,126 @@ module.exports = {
files: ['test/harden/*.js'],
rules: allMochaRulesOff,
},
{
files: ['**/*.{js,mjs,ts,tsx}'],
rules: {
'no-restricted-imports': [
2,
{
paths: [
{
name: 'lodash',
importNames: ['set', 'setWith'],
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash.set',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash.setwith',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash/set',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash/setWith',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash/fp',
importNames: ['set', 'setWith', 'assoc', 'assocPath'],
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash/fp/set',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash/fp/setWith',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash/fp/assoc',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash/fp/assocPath',
message: 'Please use @elastic/safer-lodash-set instead',
},
],
},
],
'no-restricted-modules': [
2,
{
paths: [
{
name: 'lodash.set',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash.setwith',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash/set',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
name: 'lodash/setWith',
message: 'Please use @elastic/safer-lodash-set instead',
},
],
},
],
'no-restricted-properties': [
2,
{
object: 'lodash',
property: 'set',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
object: '_',
property: 'set',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
object: 'lodash',
property: 'setWith',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
object: '_',
property: 'setWith',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
object: 'lodash',
property: 'assoc',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
object: '_',
property: 'assoc',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
object: 'lodash',
property: 'assocPath',
message: 'Please use @elastic/safer-lodash-set instead',
},
{
object: '_',
property: 'assocPath',
message: 'Please use @elastic/safer-lodash-set instead',
},
],
},
},

/**
* APM overrides
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"@elastic/good": "8.1.1-kibana2",
"@elastic/numeral": "^2.5.0",
"@elastic/request-crypto": "1.1.4",
"@elastic/safer-lodash-set": "0.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

question: are we going to keep 0.0.0 or you're planning to change it to something else before merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't planning to. The package.json version number is really only useful for things you download from npm. So me bumping it doesn't really change anything. That being said, I am planning to also release this to npm once merged. When I do that I'll bump to version 1.0.0. I could of course also do that just before the merge and then bump this reference as well... now that I think of it, I might actually do that :)

"@elastic/ui-ace": "0.2.3",
"@hapi/good-squeeze": "5.2.1",
"@hapi/wreck": "^15.0.2",
Expand Down
2 changes: 2 additions & 0 deletions packages/elastic-safer-lodash-set/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.tmp
node_modules
2 changes: 2 additions & 0 deletions packages/elastic-safer-lodash-set/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test.js
scripts
34 changes: 34 additions & 0 deletions packages/elastic-safer-lodash-set/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
The MIT License (MIT)

Copyright (c) Elasticsearch BV
Copyright (c) Brian Zengel <https://github.com/bczengel>, Ilya Mochalov <https://github.com/chrootsu>
Copyright (c) JS Foundation and other contributors <https://js.foundation/>

Lodash is based on Underscore.js, copyright Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>

This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at the following locations:
- https://github.com/lodash/lodash
- https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lodash
- https://github.com/elastic/kibana/tree/master/packages/elastic-safer-lodash-set

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading