Skip to content

Commit

Permalink
Merge ea77c72 into 5b50b35
Browse files Browse the repository at this point in the history
  • Loading branch information
niegowski committed Mar 28, 2023
2 parents 5b50b35 + ea77c72 commit b815544
Show file tree
Hide file tree
Showing 46 changed files with 4,735 additions and 2,036 deletions.
169 changes: 166 additions & 3 deletions .eslintrc.js
Expand Up @@ -13,7 +13,6 @@ module.exports = {
'node': true,
'mocha': true
},
'parser': 'babel-eslint',
'extends': [
'eslint:recommended',
'ckeditor5',
Expand Down Expand Up @@ -45,7 +44,9 @@ module.exports = {
{
'files': [
'**/*.js',
'**/*.jsx'
'**/*.jsx',
'**/*.ts',
'**/*.tsx'
],
'rules': {
'ckeditor5-rules/ckeditor-error-message': 'off'
Expand All @@ -54,11 +55,173 @@ module.exports = {
{
'files': [
'tests/**/*.js',
'tests/**/*.jsx'
'tests/**/*.jsx',
'tests/**/*.ts',
'tests/**/*.tsx'
],
'rules': {
'no-unused-expressions': 'off'
}
},
{
'files': [
'demo*/**/*.ts',
'demo*/**/*.tsx'
],
'rules': {
'ckeditor5-rules/license-header': 'off'
}
},
// TODO this is a copy from
// https://github.com/ckeditor/ckeditor5-linters-config/blob/master/packages/eslint-config-ckeditor5/.eslintrc.js#L330
// only extended with .tsx
{
files: [ '**/*.ts', '**/*.tsx' ],
plugins: [
'@typescript-eslint',
'ckeditor5-rules',
'mocha'
],
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended'
],
rules: {
'@typescript-eslint/array-type': [
'error',
{ default: 'generic' }
],
'@typescript-eslint/ban-types': [
'error',
{
types: { Function: false },
extendDefaults: true
}
],

'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'allow-as-parameter'
}
],

'@typescript-eslint/consistent-type-imports': 'error',

'@typescript-eslint/explicit-module-boundary-types': [
'error',
{ allowArgumentsExplicitlyTypedAsAny: true }
],

'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit',
overrides: {
constructors: 'off'
}
}
],

'@typescript-eslint/member-delimiter-style': 'error',

'@typescript-eslint/no-confusing-non-null-assertion': 'error',

'@typescript-eslint/no-empty-function': 'off',

'@typescript-eslint/no-empty-interface': 'off',

'@typescript-eslint/no-explicit-any': 'off',

'@typescript-eslint/no-inferrable-types': 'off',

'@typescript-eslint/no-invalid-void-type': 'error',

'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',

'@typescript-eslint/no-non-null-assertion': 'off',

'@typescript-eslint/parameter-properties': 'error',

'@typescript-eslint/type-annotation-spacing': 'error',

'@typescript-eslint/unified-signatures': 'error',

// typescript-eslint extension rules (intended to be compatible with those for .js):

'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'error',

'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{
functions: false,
classes: false,
variables: true,
typedefs: false,
ignoreTypeReferences: true
}
],

'comma-dangle': 'off',
'@typescript-eslint/comma-dangle': [ 'error', 'never' ],

'comma-spacing': 'off',
'@typescript-eslint/comma-spacing': [
'error',
{
before: false,
after: true
}
],

'func-call-spacing': 'off',
'@typescript-eslint/func-call-spacing': [ 'error', 'never' ],

'keyword-spacing': 'off',
'@typescript-eslint/keyword-spacing': 'error',

'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',

'object-curly-spacing': 'off',
'@typescript-eslint/object-curly-spacing': [ 'error', 'always' ],

'quotes': 'off',
'@typescript-eslint/quotes': [ 'error', 'single' ],

'semi': 'off',
'@typescript-eslint/semi': 'error',

'space-before-blocks': 'off',
'@typescript-eslint/space-before-blocks': [ 'error', 'always' ],

'space-before-function-paren': 'off',
'@typescript-eslint/space-before-function-paren': [
'error',
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always'
}
],

'space-infix-ops': 'off',
'@typescript-eslint/space-infix-ops': 'error',

'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error'
}
},
{
files: [ '**/tests/**/*.ts', '**/tests/**/*.tsx' ],
rules: {
'@typescript-eslint/no-unused-expressions': 'off'
}
}
]
};
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@ node_modules/
coverage/
dist/
.idea
.tmp
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -13,11 +13,11 @@ before_install:
- export COVERALLS_SERVICE_JOB_ID=$( TRAVIS_JOB_ID )
- export START_TIME=$( date +%s )
install:
- npm install
- yarn install
script:
- npm run lint
- npm run build
- npm run coverage
- yarn run lint
- yarn run build
- yarn run coverage
- if [[ $TRAVIS_TEST_RESULT -eq 0 ]]; then cat coverage/lcov.info | ./node_modules/.bin/coveralls; fi
after_script:
- export END_TIME=$( date +%s )
Expand Down
34 changes: 34 additions & 0 deletions demo-react-16/index.html
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>CKEditor 5 – React Component – demo</title>
<style>
body {
max-width: 800px;
margin: 20px auto;
}

p.info, h1, h2.subtitle {
text-align: center;
}

.buttons {
margin: 10px 0;
}

.buttons button {
margin-right: 5px;
}
</style>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>


24 changes: 24 additions & 0 deletions demo-react-16/package.json
@@ -0,0 +1,24 @@
{
"name": "demo",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@ckeditor/ckeditor5-react": "file:..",
"@ckeditor/ckeditor5-build-classic": "37.0.0-alpha.3",
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"devDependencies": {
"@types/react": "^16.14.35",
"@types/react-dom": "^16.9.18",
"@vitejs/plugin-react": "^3.1.0",
"typescript": "^4.9.3",
"vite": "^4.2.0"
}
}
File renamed without changes
61 changes: 61 additions & 0 deletions demo-react-16/src/App.tsx
@@ -0,0 +1,61 @@
import React, { type ReactNode } from 'react';
import EditorDemo from './EditorDemo';
import ContextDemo from './ContextDemo';

type AppState = {
demo: 'editor' | 'context';
};

const editorContent = `
<h2>Sample</h2>
<p>This is an instance of the <a href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/overview.html#classic-editor">
classic editor build</a>.
</p>
<figure class="image">
<img src="/sample.jpg" alt="CKEditor 5 Sample image." />
</figure>
<p>You can use this sample to validate whether your
<a href="https://ckeditor.com/docs/ckeditor5/latest/builds/guides/development/custom-builds.html">custom build</a> works fine.</p>
`;

// eslint-disable-next-line @typescript-eslint/ban-types
export default class App extends React.Component<{}, AppState> {
public state: AppState = {
demo: 'editor'
};

public render(): ReactNode {
return (
<>
<h1>CKEditor 5 – React Component – development sample</h1>

<div className="buttons" style={{ textAlign: 'center' }}>
<button
onClick={ () => this.showDemo( 'editor' ) }
disabled={ this.state.demo == 'editor' }
>
Editor demo
</button>

<button
onClick={ () => this.showDemo( 'context' ) }
disabled={ this.state.demo == 'context' }
>
Context demo
</button>
</div>
{
this.state.demo == 'editor' ?
<EditorDemo content={ editorContent }/> :
<ContextDemo content={ editorContent }/>
}
</>
);
}

private showDemo( demo: AppState[ 'demo' ] ) {
this.setState( {
demo
} );
}
}

0 comments on commit b815544

Please sign in to comment.