Skip to content

Commit

Permalink
Format remaining files with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-koehler committed Apr 21, 2023
1 parent 7b6f73c commit e1622da
Show file tree
Hide file tree
Showing 98 changed files with 1,193 additions and 1,141 deletions.
46 changes: 23 additions & 23 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/javascript-node
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 14, 16
"args": {
"VARIANT": "14"
}
},
// Set *default* container specific settings.json values on container create.
// Add the IDs of extensions you want installed when the container is created.
"customizations": {
"extensions": [
"DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"vue.volar"
]
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm ci && npm run init && npm run build",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
}
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 14, 16
"args": {
"VARIANT": "14"
}
},
// Set *default* container specific settings.json values on container create.
// Add the IDs of extensions you want installed when the container is created.
"customizations": {
"extensions": [
"DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"vue.volar"
]
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm ci && npm run init && npm run build",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
}
4 changes: 1 addition & 3 deletions .github/config/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
"sort": "DESC",
"pr_template": "- [${{LABELS}}] ${{TITLE}} (#${{NUMBER}})",
"template": "${{UNCATEGORIZED}}",
"ignore_labels": [
"dependencies"
]
"ignore_labels": ["dependencies"]
}
52 changes: 26 additions & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ jobs:
- windows-latest
name: Run on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Build
run: |
npm ci
npm run init
npm run build
npm run bundle
- name: Test
if: matrix.os == 'windows-latest'
run: |
npm run test
- name: Test & Coverage
if: matrix.os == 'ubuntu-latest'
run: |
npm run test-cov
npm run check-format
npm run merge-report && cat coverage/lcov.info
- name: Upload Coveralls Report
if: success() && matrix.os == 'ubuntu-latest'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14
- name: Build
run: |
npm ci
npm run init
npm run build
npm run bundle
- name: Test
if: matrix.os == 'windows-latest'
run: |
npm run test
- name: Test & Coverage
if: matrix.os == 'ubuntu-latest'
run: |
npm run test-cov
npm run check-format
npm run merge-report && cat coverage/lcov.info
- name: Upload Coveralls Report
if: success() && matrix.os == 'ubuntu-latest'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
release:
if: |
if: |
startsWith(github.ref, 'refs/tags/v') &&
!contains(github.ref, 'alpha') &&
!contains(github.ref, 'beta') &&
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
singleQuote: true,
jsxSingleQuote: true,
endOfLine: 'auto',
}
};
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"DavidAnson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-vscode-remote.remote-containers",
"ms-vscode-remote.remote-containers"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
}
16 changes: 8 additions & 8 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
},
"search.exclude": {
"**/docs": true,
"**/node_modules": true,
"**/lib": true
},
}
}
}
90 changes: 52 additions & 38 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@ interface TesterContext {
config: any;
}

type Tester = (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => boolean;
type RankedTester = (uischema: UISchemaElement, schema: JsonSchema, context: TesterContext) => number;
type Tester = (
uischema: UISchemaElement,
schema: JsonSchema,
context: TesterContext
) => boolean;
type RankedTester = (
uischema: UISchemaElement,
schema: JsonSchema,
context: TesterContext
) => number;
```

This allows the testers to resolve any `$ref` they might encounter in their handed over `schema` by using the context's `rootSchema`.
Expand All @@ -50,30 +58,37 @@ To restore the old behavior, you can use `json-schema-ref-parser` or other libra
```ts
import React, { useState } from 'react';
import { JsonForms } from '@jsonforms/react';
import { materialCells, materialRenderers } from '@jsonforms/material-renderers';
import {
materialCells,
materialRenderers,
} from '@jsonforms/material-renderers';
import $RefParser from '@apidevtools/json-schema-ref-parser';
import JsonRefs from 'json-refs';

import mySchemaWithReferences from 'myschema.json';

const refParserOptions = {
dereference: {
circular: false
}
}
circular: false,
},
};

function App() {
const [data, setData] = useState(initialData);
const [resolvedSchema, setSchema] = useState();

useEffect(() => {
$RefParser.dereference(mySchemaWithReferences).then(res => setSchema(res.$schema));
$RefParser
.dereference(mySchemaWithReferences)
.then((res) => setSchema(res.$schema));
// or
JsonRefs.resolveRefs(mySchemaWithReferences).then(res => setSchema(res.resolved));
},[]);
JsonRefs.resolveRefs(mySchemaWithReferences).then((res) =>
setSchema(res.resolved)
);
}, []);

if(resolvedSchema === undefined) {
return <div> Loading... </div>
if (resolvedSchema === undefined) {
return <div> Loading... </div>;
}

return (
Expand Down Expand Up @@ -143,12 +158,12 @@ export const schema = {
type: 'object',
properties: {
name: {
type: 'string'
}
type: 'string',
},
},
required: ['name']
required: ['name'],
};
export const data = {name: 'Send email to Adrian'};
export const data = { name: 'Send email to Adrian' };

@Component({
selector: 'app-root',
Expand All @@ -160,7 +175,7 @@ export const data = {name: 'Send email to Adrian'};
[renderers]="renderers"
(dataChange)="onDataChange($event)"
></jsonforms>
`
`,
})
export class AppComponent {
readonly renderers = angularMaterialRenderers;
Expand Down Expand Up @@ -201,15 +216,12 @@ All current Redux functionally can also be achieved with the standalone version.
Previously the store was initialized like this:

```ts
const store = createStore(
combineReducers({ jsonforms: jsonformsReducer() }),
{
jsonforms: {
cells: materialCells,
renderers: materialRenderers
}
}
);
const store = createStore(combineReducers({ jsonforms: jsonformsReducer() }), {
jsonforms: {
cells: materialCells,
renderers: materialRenderers,
},
});
store.dispatch(Actions.init(data, schema, uischema));
return (
<Provider store={store}>
Expand Down Expand Up @@ -250,7 +262,7 @@ Within the standalone version, the renderer can just be provided to the `<JsonFo
const renderers = [
...materialRenderers,
// register custom renderer
{ tester: customControlTester, renderer: CustomControl }
{ tester: customControlTester, renderer: CustomControl },
];

const MyApp = () => (
Expand All @@ -259,7 +271,6 @@ const MyApp = () => (
renderers={renderers}
/>
);

```

##### Example 3: Listen to data and validation changes
Expand All @@ -286,7 +297,10 @@ If you want to keep using the Redux variant of JSON Forms for now (which is not
The new imports are available at `@jsonforms/react/lib/redux`, i.e.

```ts
import { jsonformsReducer, JsonFormsReduxProvider } from '@jsonforms/react/lib/redux';
import {
jsonformsReducer,
JsonFormsReduxProvider,
} from '@jsonforms/react/lib/redux';
```

## Migrating from JSON Forms 1.x (AngularJS 1.x)
Expand All @@ -298,8 +312,8 @@ The complexity of the migration of an existing JSON Forms 1.x application, which
There are two big changes between JSON Forms 1 and JSON Forms 2 you need to understand when migrating your existing application.

1. JSON Forms 2.x does not rely on any specific UI framework [or library].
The `2.0.0` initial release featured renderers based on [React](https://reactjs.org).
An [Angular](https://angular.io) based renderer set was released with `2.1.0`.
The `2.0.0` initial release featured renderers based on [React](https://reactjs.org).
An [Angular](https://angular.io) based renderer set was released with `2.1.0`.

2. Since JSON Forms 2.x maintains its internal state via [redux](https://redux.js.org/), you will need to add it as a dependency to your application.

Expand All @@ -314,20 +328,20 @@ Instead of:

```ts
const uischema = {
type: 'Control',
scope: {
$ref: '#/properties/name'
}
}
type: 'Control',
scope: {
$ref: '#/properties/name',
},
};
```

simply write:

```ts
const uischema = {
type: 'Control',
scope: '#/properties/name'
}
type: 'Control',
scope: '#/properties/name',
};
```

Otherwise the UI schema remains unchanged and works like in JSON Forms 1.x.
Expand Down
Loading

0 comments on commit e1622da

Please sign in to comment.