Skip to content

Commit

Permalink
Preview/refactor encoding (#152)
Browse files Browse the repository at this point in the history
* use eslint

* Publish

 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]

* reencode morphic

* Publish

 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
 - @morphic-ts/[email protected]
  • Loading branch information
sledorze authored Dec 27, 2020
1 parent cfcf2f6 commit 1cf4e10
Show file tree
Hide file tree
Showing 251 changed files with 3,314 additions and 3,161 deletions.
67 changes: 67 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* eslint-disable no-undef */
module.exports = {
ignorePatterns: ['dtslint/', 'lib/', 'es6/', 'build/', 'react/demo/'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module'
},
env: {
browser: true,
node: true,
jasmine: true,
jest: true,
'jest/globals': true
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx']
},
'import/resolver': {
typescript: {
alwaysTryTypes: true
}
}
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended' // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
plugins: ['import', 'sort-destructure-keys', 'simple-import-sort', 'jest'], // , 'codegen'],
rules: {
// codegen
// 'codegen/codegen': 'error',

// eslint built-in rules, sorted alphabetically
'no-fallthrough': 'off',
'no-irregular-whitespace': 'off',
'object-shorthand': 'error',
'prefer-destructuring': 'off',
'sort-imports': 'off',

// all other rules, sorted alphabetically
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'import/no-unresolved': 'error',
'import/order': 'off',
'simple-import-sort/imports': 'error',
'sort-destructure-keys/sort-destructure-keys': 'error'
}
}
83 changes: 82 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,86 @@
"typescript.tsdk": "./node_modules/typescript/lib",
"prettier.configPath": "./prettier.config.js",
"editor.tabCompletion": "onlySnippets",
"cSpell.words": ["ADTs", "Greenkeeper", "Morphic's", "Reinterpreter", "combinator", "combinators"]
"cSpell.words": [
"ADTs",
"Greenkeeper",
"Morphic's",
"Reinterpreter",
"combinator",
"combinators"
],
"editor.defaultFormatter": "dbaeumer.vscode-eslint",

"editor.cursorStyle": "block",
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.formatOnType": true,
"editor.autoIndent": "full",
"workbench.editor.showIcons": true,
"search.exclude": {
"**/node_modules": false,
"**/bower_components": true,
"**/build": true,
".tmp": true
},
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true,
"**/.temp/**": true,
"**/.tmp/**": true,
"**/build/**": true,
"**/.tmp": true,
".tmp": true,
"**/target": true
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.DS_Store": true,
"**/.git/objects": true,
"**/node_modules": false,
"**/.temp/**": true,
"**/.tmp/**": true,
"**/build/**": false,
"**/.tmp": true,
".tmp": true
},
"extensions.autoUpdate": true,
"tslint.packageManager": "npm",
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.formatOnSave": true,
"eslint.format.enable": true,

"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"prettier.disableLanguages": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"eslint.validate": ["markdown", "javascript", "typescript"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": false
},
"eslint.alwaysShowStatus": true,
"eslint.run": "onSave",
"eslint.packageManager": "yarn"
}
20 changes: 17 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
"workspaces": [
"packages/*"
],
"scripts": {
"fix-eslint": "eslint --fix --ext .ts ./packages"
},
"devDependencies": {
"@types/chai": "4.2.11",
"@types/jest": "25.2.3",
"@types/jest": "^26.0.19",
"@types/node": "13.13.3",
"chai": "4.2.0",
"docs-ts": "^0.2.1",
Expand All @@ -19,7 +22,7 @@
"import-path-rewrite": "github:mikearnaldi/import-path-rewrite",
"io-ts": "^2.1.3",
"io-ts-types": "^0.5.6",
"jest": "^25.1.0",
"jest": "^26.6.3",
"lerna": "^3.20.2",
"mocha": "^7.0.0",
"monocle-ts": "^2.0.1",
Expand All @@ -31,7 +34,18 @@
"tslint": "6.1.2",
"tslint-config-standard": "^9.0.0",
"typescript": "^4.1.3",
"yarn-deduplicate": "2.0.0"
"yarn-deduplicate": "2.0.0",
"eslint": "^7.15.0",
"@typescript-eslint/eslint-plugin":"^4.10.0",
"@typescript-eslint/parser": "^4.10.0",
"eslint-config-prettier": "^7.0.0",
"eslint-import-resolver-typescript": "^2.3.0",
"eslint-plugin-codegen": "^0.14.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-sort-destructure-keys": "^1.3.5"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion packages/morphic-adt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@morphic-ts/adt",
"version": "3.0.0-alpha.0",
"version": "3.0.0-alpha.1",
"description": "Morphic ADT provides Algebraic Data Type manipulation in Typescript",
"author": "Stéphane Le Dorze <[email protected]>",
"homepage": "",
Expand Down
5 changes: 3 additions & 2 deletions packages/morphic-adt/src/ctors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { Remove, ExtractUnion } from './utils'
import type { KeysDefinition, Tagged } from '.'
import { mapWithIndex } from 'fp-ts/Record'

import type { KeysDefinition, Tagged } from '.'
import type { ExtractUnion, Remove } from './utils'

/**
* @since 0.0.1
*/
Expand Down
16 changes: 8 additions & 8 deletions packages/morphic-adt/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { ElemType, ExtractUnion, ExcludeUnion } from './utils'
import * as M from './monocle'
import * as Ma from './matcher'
import * as PU from './predicates'
import * as CU from './ctors'
import { intersection, difference, reduceRight } from 'fp-ts/ReadonlyArray'
import { array } from 'fp-ts/Array'
import { array, difference, intersection, reduceRight } from 'fp-ts/Array'
import { eqString } from 'fp-ts/Eq'
import { identity, tuple } from 'fp-ts/function'
import { fromFoldable } from 'fp-ts/Record'
import { tuple, identity } from 'fp-ts/function'

import * as CU from './ctors'
import * as Ma from './matcher'
import * as M from './monocle'
import * as PU from './predicates'
import type { ElemType, ExcludeUnion, ExtractUnion } from './utils'

/**
* @since 0.0.1
Expand Down
1 change: 1 addition & 0 deletions packages/morphic-adt/src/matcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { none } from 'fp-ts/Option'
import { Lens, Optional } from 'monocle-ts'

import type { KeysDefinition } from '.'

type ValueByKeyByTag<Union extends Record<any, any>, Tags extends keyof Union = keyof Union> = {
Expand Down
4 changes: 2 additions & 2 deletions packages/morphic-adt/src/monocle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Option } from 'fp-ts/Option'
import type { Predicate, Refinement } from 'fp-ts/function'
import type { Option } from 'fp-ts/Option'
import type { At, LensFromPath } from 'monocle-ts'
import { Lens, Optional, Prism, Index } from 'monocle-ts'
import { Index, Lens, Optional, Prism } from 'monocle-ts'

interface LensFromProp<S> {
<P extends keyof S>(prop: P): Lens<S, S[P]>
Expand Down
5 changes: 3 additions & 2 deletions packages/morphic-adt/src/predicates.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ExtractUnion, ElemType } from './utils'
import type { KeysDefinition } from '.'
import { mapWithIndex } from 'fp-ts/Record'

import type { KeysDefinition } from '.'
import type { ElemType, ExtractUnion } from './utils'

/**
* @since 0.0.1
*/
Expand Down
7 changes: 4 additions & 3 deletions packages/morphic-adt/test/adt.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as chai from 'chai'
import * as O from 'fp-ts/Option'
import * as M from 'monocle-ts'
import * as chai from 'chai'
import { unionADT, intersectADT, makeADT, ofType } from '../src'

import { intersectADT, makeADT, ofType, unionADT } from '../src'

describe('Builder', () => {
interface Foo {
Expand Down Expand Up @@ -43,7 +44,7 @@ describe('Builder', () => {
bar: ofType<Bar>()
})

const { fold, match, createReducer, createPartialReducer, transform, strict, matchLens, matchOptional } = fooBar
const { createPartialReducer, createReducer, fold, match, matchLens, matchOptional, strict, transform } = fooBar
const fooA = fooBar.of.foo({ a: 'a', b: 12 })
const barA = fooBar.of.bar({ c: 'a', d: 12 })
const barB = fooBar.of.bar({ c: 'b', d: 13 })
Expand Down
28 changes: 1 addition & 27 deletions packages/morphic-algebras/docs/modules/core.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ parent: Modules
<h2 class="text-delta">Table of contents</h2>

- [Algebra (type alias)](#algebra-type-alias)
- [Algebra1 (type alias)](#algebra1-type-alias)
- [Algebra2 (type alias)](#algebra2-type-alias)
- [GetAlgebra (type alias)](#getalgebra-type-alias)

---
Expand All @@ -20,37 +18,13 @@ parent: Modules
**Signature**

```ts
export type Algebra<AllAlgebra extends AlgebraURIS, Interp, Env> = UnionToIntersection<
export type Algebra<AllAlgebra extends AlgebraURIS, Interp extends URIS, Env extends AnyEnv> = UnionToIntersection<
AlgAlgebra<Interp, Env>[AllAlgebra]
>
```
Added in v0.0.1
# Algebra1 (type alias)
**Signature**
```ts
export type Algebra1<AllAlgebra extends AlgebraURIS, Interp extends URIS, Env extends AnyEnv> = UnionToIntersection<
AlgAlgebra1<Interp, Env>[AllAlgebra]
>
```
Added in v0.0.1
# Algebra2 (type alias)
**Signature**
```ts
export type Algebra2<AllAlgebra extends AlgebraURIS, Interp extends URIS2, Env extends AnyEnv> = UnionToIntersection<
AlgAlgebra2<Interp, Env>[AllAlgebra]
>
```
Added in v0.0.1
# GetAlgebra (type alias)
**Signature**
Expand Down
30 changes: 1 addition & 29 deletions packages/morphic-algebras/docs/modules/hkt.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ parent: Modules
<h2 class="text-delta">Table of contents</h2>

- [Algebra (interface)](#algebra-interface)
- [Algebra1 (interface)](#algebra1-interface)
- [Algebra2 (interface)](#algebra2-interface)
- [AlgebraURIS (type alias)](#algebrauris-type-alias)

---
Expand All @@ -20,33 +18,7 @@ parent: Modules
**Signature**

```ts
export interface Algebra<F, Env> {
_AF: F
_ENV: Env
}
```

Added in v0.0.1

# Algebra1 (interface)

**Signature**

```ts
export interface Algebra1<F extends URIS, Env extends AnyEnv> {
_AF: F
_ENV: Env
}
```

Added in v0.0.1

# Algebra2 (interface)

**Signature**

```ts
export interface Algebra2<F extends URIS2, Env extends AnyEnv> {
export interface Algebra<F extends URIS, Env extends AnyEnv> {
_AF: F
_ENV: Env
}
Expand Down
4 changes: 2 additions & 2 deletions packages/morphic-algebras/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@morphic-ts/algebras",
"version": "3.0.0-alpha.0",
"version": "3.0.0-alpha.2",
"description": "Morphic core Algebra package",
"author": "Stéphane Le Dorze <[email protected]>",
"homepage": "",
Expand All @@ -21,7 +21,7 @@
"es6"
],
"dependencies": {
"@morphic-ts/common": "^3.0.0-alpha.0"
"@morphic-ts/common": "^3.0.0-alpha.2"
},
"scripts": {
"lint": "tslint -p tsconfig.tslint.json src/**/*.ts test/**/*.ts",
Expand Down
Loading

0 comments on commit 1cf4e10

Please sign in to comment.