-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup,
@datakit/eslint@0.1.0
, @datakit/tx@0.1.0
- Loading branch information
0 parents
commit 8ea4f74
Showing
28 changed files
with
2,492 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
_/ | ||
**/*.idea.js | ||
**/*.todo.js | ||
coverage/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {readFileSync} from 'node:fs'; | ||
|
||
export const gitIgnoredPatterns = | ||
readFileSync('.gitignore', 'utf8') | ||
.split('\n') | ||
.filter(line => line && !line.startsWith('#')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
publish-branch = dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Luca Bonavita | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# DataKit | ||
|
||
- `@datakit/eslint`: config objects for eslint | ||
- `@datakit/tx`: utilities for data transformation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {jsConfig, jsdocConfig, styleConfig} from '@datakit/eslint'; | ||
|
||
import {gitIgnoredPatterns} from './.gitignore.js'; | ||
|
||
export default [ | ||
{ | ||
ignores: gitIgnoredPatterns, | ||
}, | ||
...jsConfig, | ||
...jsdocConfig, | ||
...styleConfig, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"bugs": { | ||
"url": "https://github.com/mindrones/datakit/issues" | ||
}, | ||
"description": "A collection of utilities for data transformation and visualisation", | ||
"devDependencies": { | ||
"@datakit/eslint": "workspace:", | ||
"@vitest/coverage-v8": "^2.0.5", | ||
"vitest": "^2.0.5" | ||
}, | ||
"homepage": "https://github.com/mindrones/datakit", | ||
"license": "MIT", | ||
"name": "datakit-monorepo", | ||
"private": true, | ||
"scripts": { | ||
"coverage": "vitest run --coverage", | ||
"lint": "eslint", | ||
"publish": "pnpm publish -r", | ||
"publishDry": "pnpm publish -r --dry-run", | ||
"test": "vitest" | ||
}, | ||
"type": "module", | ||
"workspaces": [ | ||
"packages/*" | ||
] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# @datakit/eslint | ||
|
||
## v0.1.0 | ||
|
||
Exports `jsConfig`, `styleConfig`, `jsdocConfig` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Luca Bonavita | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# `@datakit/eslint` | ||
|
||
Eslint configurations to be shared across `@datakit` packages. | ||
|
||
This could be used in apps installing `@datakit` packages to maintain | ||
linting and style consistency with those packages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"bugs": { | ||
"url": "https://github.com/mindrones/datakit/issues" | ||
}, | ||
"dependencies": { | ||
"@eslint/js": "^9.9.1", | ||
"@stylistic/eslint-plugin-js": "^2.6.4", | ||
"eslint": "^9.9.1", | ||
"eslint-plugin-jsdoc": "^50.2.2", | ||
"globals": "^15.9.0" | ||
}, | ||
"description": "eslint configurations used by @datakit/* packages.", | ||
"files": [ | ||
"src/**/*.js", | ||
"!src/**/*.test.js", | ||
"CHANGELOG.md", | ||
"README.md" | ||
], | ||
"homepage": "https://github.com/mindrones/datakit", | ||
"keywords": [ | ||
"configuration", | ||
"eslint" | ||
], | ||
"license": "MIT", | ||
"main": "src/index.js", | ||
"name": "@datakit/eslint", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"directory": "packages/eslint", | ||
"type": "git", | ||
"url": "github:mindrones/datakit" | ||
}, | ||
"type": "module", | ||
"version": "0.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pluginJs from '@eslint/js'; | ||
import pluginJsStyle from '@stylistic/eslint-plugin-js'; | ||
import pluginJsDoc from 'eslint-plugin-jsdoc'; | ||
import globals from 'globals'; | ||
|
||
export const jsConfig = [ | ||
{ | ||
languageOptions: { | ||
// https://github.com/sindresorhus/globals | ||
// A value of `false` indicates that the variable should be considered read-only. | ||
globals: { | ||
...globals.browser, | ||
...globals.node | ||
} | ||
}, | ||
linterOptions: { | ||
reportUnusedDisableDirectives: 'warn' | ||
} | ||
}, | ||
pluginJs.configs.recommended, // {rules} | ||
]; | ||
|
||
export const styleConfig = [ | ||
{ | ||
plugins: { | ||
'@stylistic/js': pluginJsStyle | ||
}, | ||
rules: { | ||
'@stylistic/js/indent': ['warn', 'tab', { | ||
MemberExpression: 'off', | ||
SwitchCase: 1, | ||
}], | ||
'@stylistic/js/quotes': ['warn', 'single', {avoidEscape: true}] | ||
} | ||
}, | ||
]; | ||
|
||
export const jsdocConfig = [ | ||
pluginJsDoc.configs['flat/recommended'], // {plugins, rules} | ||
{ | ||
rules: { | ||
'jsdoc/require-param-description': 'off', | ||
'jsdoc/require-returns-description': 'off', | ||
'jsdoc/tag-lines': 'off', | ||
} | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @datakit/tx | ||
|
||
## v0.1.0 | ||
|
||
- Re-exports all functions from `@svizzle/utils@0.21.0` | ||
- Re-exports `compare` from `just-compare@2.3.0` as `areEquals` | ||
- add: `getRandomItemOf`, `getRandomIndexOf`, `joinWithNewline` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Luca Bonavita | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# `@datakit/tx` | ||
|
||
Utilities for data transformation. | ||
|
||
This library re-exports all functions from `@svizzle/utils@0.21.0` and | ||
provides new ones. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"bugs": { | ||
"url": "https://github.com/mindrones/datakit/issues" | ||
}, | ||
"dependencies": { | ||
"@svizzle/utils": "catalog:", | ||
"just-compare": "catalog:", | ||
"lamb": "catalog:" | ||
}, | ||
"description": "Utilities for data transformation.", | ||
"files": [ | ||
"src/**/*.js", | ||
"!src/**/*.test.js", | ||
"CHANGELOG.md", | ||
"README.md" | ||
], | ||
"homepage": "https://github.com/mindrones/datakit", | ||
"keywords": [ | ||
"@svizzle/utils", | ||
"data transformation", | ||
"functional programming" | ||
], | ||
"license": "MIT", | ||
"main": "src/index.js", | ||
"name": "@datakit/tx", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"directory": "packages/tx", | ||
"type": "git", | ||
"url": "github:mindrones/datakit" | ||
}, | ||
"type": "module", | ||
"version": "0.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {getRandomIndexOf} from './array-number.js'; | ||
|
||
/** | ||
* Return a random item of the passed array | ||
* | ||
* @function | ||
* @param {Array} array | ||
* @returns {any} | ||
* | ||
* @example | ||
> getRandomItem = getRandomItemOf([0, 1, 2, 3]) | ||
> getRandomItem() | ||
2 | ||
> getRandomItem() | ||
1 | ||
> getRandomItem = getRandomItemOf([{a: 0}, {a: 1}, {a: 2}, {a: 3}]) | ||
> getRandomItem() | ||
{a: 3} | ||
> getRandomItem() | ||
{a: 0} | ||
* | ||
* @since 0.1.0 | ||
*/ | ||
export const getRandomItemOf = array => { | ||
const index = getRandomIndexOf(array); | ||
|
||
return array[index]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {makeIsIncluded} from '@svizzle/utils'; | ||
import {describe, it, expect} from 'vitest'; | ||
|
||
import {getRandomItemOf} from './array-any.js'; | ||
|
||
describe('getRandomItemOf', () => { | ||
it('get a random number in the array', () => { | ||
const nums = [0, 1, 2, 3]; | ||
const isIncluded = makeIsIncluded(nums); | ||
|
||
const number = getRandomItemOf(nums); | ||
expect(number).toSatisfy(isIncluded); | ||
}); | ||
it('get a random object in the array', () => { | ||
const objs = [{a: 0}, {a: 1}, {a: 2}, {a: 3}]; | ||
const isIncluded = makeIsIncluded(objs); | ||
|
||
const obj = getRandomItemOf(objs); | ||
expect(obj).toSatisfy(isIncluded); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as _ from 'lamb'; | ||
|
||
/** | ||
* Return the index of a random item of the passed array | ||
* | ||
* @function | ||
* @param {Array} array | ||
* @returns {number} | ||
* | ||
* @example | ||
> getRandomIndex = getRandomIndexOf([0, 1, 2, 3]) | ||
> getRandomIndex() | ||
2 | ||
> getRandomItem() | ||
1 | ||
* | ||
* @since 0.1.0 | ||
*/ | ||
export const getRandomIndexOf = array => { | ||
const index = _.randomInt(0, array.length - 1); | ||
|
||
return index; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {describe, it, expect} from 'vitest'; | ||
|
||
import {getRandomIndexOf} from './array-number.js'; | ||
|
||
describe('getRandomIndexOf', () => { | ||
it('get a random index in the array', () => { | ||
const index = getRandomIndexOf([0, 1, 2, 3]); | ||
expect(index).toBeLessThanOrEqual(3); | ||
expect(index).toBeGreaterThanOrEqual(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as _ from 'lamb'; | ||
|
||
/** | ||
* Return a string joining the provided array items with a return | ||
* @see {@link https://ascartabelli.github.io/lamb/module-lamb.html#joinWith|joinWith} | ||
* | ||
* @function | ||
* @param {Array} array | ||
* @returns {string} | ||
* | ||
* @example | ||
> joinWithNewline([1, 2, 3]) | ||
'1\n2\n3' | ||
> joinWithNewline(['a', 'b', 'c']) | ||
'a\nb\nc' | ||
* | ||
* @since 0.1.0 | ||
*/ | ||
export const joinWithNewline = _.joinWith('\n'); |
Oops, something went wrong.