mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-19 05:09:41 +02:00
Babel eslint parser (#9)
* Move testing to 3001 port Create separate database for testing Add runtime configuration file support * Add babel-eslint parser
This commit is contained in:
parent
452d0ae816
commit
ff09f695d0
4 changed files with 43 additions and 14 deletions
|
@ -11,5 +11,10 @@
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-unused-expressions": 0,
|
"no-unused-expressions": 0,
|
||||||
"chai-friendly/no-unused-expressions": 2
|
"chai-friendly/no-unused-expressions": 2
|
||||||
|
},
|
||||||
|
"parser": "babel-eslint",
|
||||||
|
"globals": {
|
||||||
|
"fetch": true,
|
||||||
|
"alert": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
"@babel/preset-env": "^7.1.0",
|
"@babel/preset-env": "^7.1.0",
|
||||||
"autoprefixer": "^9.1.3",
|
"autoprefixer": "^9.1.3",
|
||||||
"babel": "^6.23.0",
|
"babel": "^6.23.0",
|
||||||
|
"babel-eslint": "^10.0.1",
|
||||||
"babel-loader": "^8.0.2",
|
"babel-loader": "^8.0.2",
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"chai-http": "^4.0.0",
|
"chai-http": "^4.0.0",
|
||||||
|
@ -62,7 +63,6 @@
|
||||||
"postcss-nested-ancestors": "^2.0.0",
|
"postcss-nested-ancestors": "^2.0.0",
|
||||||
"postcss-nesting": "^6.0.0",
|
"postcss-nesting": "^6.0.0",
|
||||||
"postcss-smart-import": "^0.7.6",
|
"postcss-smart-import": "^0.7.6",
|
||||||
"rimraf": "^2.6.2",
|
|
||||||
"sinon": "^6.3.5",
|
"sinon": "^6.3.5",
|
||||||
"webpack": "^4.17.1",
|
"webpack": "^4.17.1",
|
||||||
"webpack-cli": "^3.1.0"
|
"webpack-cli": "^3.1.0"
|
||||||
|
|
|
@ -7,18 +7,21 @@
|
||||||
* @property {string} version - used Editor version
|
* @property {string} version - used Editor version
|
||||||
* @property {number} time - saving time
|
* @property {number} time - saving time
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* @class Writing
|
||||||
|
* @classdesc Class for create/edit pages
|
||||||
|
*/
|
||||||
export default class Writing {
|
export default class Writing {
|
||||||
/**
|
/**
|
||||||
* Creates base properties
|
* Creates base properties
|
||||||
*/
|
*/
|
||||||
constructor(){
|
constructor() {
|
||||||
this.editor = null;
|
this.editor = null;
|
||||||
this.nodes = {
|
this.nodes = {
|
||||||
editorWrapper: null,
|
editorWrapper: null,
|
||||||
saveButton: null,
|
saveButton: null,
|
||||||
parentIdSelector: null,
|
parentIdSelector: null
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +56,7 @@ export default class Writing {
|
||||||
* Loads class for working with Editor
|
* Loads class for working with Editor
|
||||||
* @return {Promise<Editor>}
|
* @return {Promise<Editor>}
|
||||||
*/
|
*/
|
||||||
async loadEditor(){
|
async loadEditor() {
|
||||||
const {default: Editor} = await import(/* webpackChunkName: "editor" */ './../classes/editor');
|
const {default: Editor} = await import(/* webpackChunkName: "editor" */ './../classes/editor');
|
||||||
|
|
||||||
return new Editor();
|
return new Editor();
|
||||||
|
@ -64,7 +67,7 @@ export default class Writing {
|
||||||
* @throws {Error} - validation error
|
* @throws {Error} - validation error
|
||||||
* @return {Promise.<{parent: string, body: {editorData}}>}
|
* @return {Promise.<{parent: string, body: {editorData}}>}
|
||||||
*/
|
*/
|
||||||
async getData(){
|
async getData() {
|
||||||
const editorData = await this.editor.save();
|
const editorData = await this.editor.save();
|
||||||
const firstBlock = editorData.blocks.length ? editorData.blocks[0] : null;
|
const firstBlock = editorData.blocks.length ? editorData.blocks[0] : null;
|
||||||
const title = firstBlock && firstBlock.type === 'header' ? firstBlock.data.text : null;
|
const title = firstBlock && firstBlock.type === 'header' ? firstBlock.data.text : null;
|
||||||
|
@ -82,7 +85,7 @@ export default class Writing {
|
||||||
/**
|
/**
|
||||||
* Handler for clicks on the Save button
|
* Handler for clicks on the Save button
|
||||||
*/
|
*/
|
||||||
async saveButtonClicked(){
|
async saveButtonClicked() {
|
||||||
try {
|
try {
|
||||||
const writingData = await this.getData();
|
const writingData = await this.getData();
|
||||||
|
|
||||||
|
@ -90,24 +93,23 @@ export default class Writing {
|
||||||
let response = await fetch('/page', {
|
let response = await fetch('/page', {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json; charset=utf-8",
|
'Content-Type': 'application/json; charset=utf-8'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(writingData),
|
body: JSON.stringify(writingData)
|
||||||
});
|
});
|
||||||
|
|
||||||
response = await response.json();
|
response = await response.json();
|
||||||
|
|
||||||
if (response.success){
|
if (response.success) {
|
||||||
document.location = '/page/' + response.result._id;
|
document.location = '/page/' + response.result._id;
|
||||||
} else {
|
} else {
|
||||||
alert(response.error);
|
alert(response.error);
|
||||||
console.log('Validation failed:', response.error);
|
console.log('Validation failed:', response.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (sendingError) {
|
} catch (sendingError) {
|
||||||
console.log('Saving request failed:', sendingError);
|
console.log('Saving request failed:', sendingError);
|
||||||
}
|
}
|
||||||
} catch (savingError){
|
} catch (savingError) {
|
||||||
alert(savingError);
|
alert(savingError);
|
||||||
console.log('Saving error: ', savingError);
|
console.log('Saving error: ', savingError);
|
||||||
}
|
}
|
||||||
|
|
24
yarn.lock
24
yarn.lock
|
@ -237,6 +237,10 @@
|
||||||
version "7.0.0-beta.51"
|
version "7.0.0-beta.51"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.0.0-beta.51.tgz#27cec2df409df60af58270ed8f6aa55409ea86f6"
|
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.0.0-beta.51.tgz#27cec2df409df60af58270ed8f6aa55409ea86f6"
|
||||||
|
|
||||||
|
"@babel/parser@^7.0.0":
|
||||||
|
version "7.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.2.tgz#85c5c47af6d244fab77bce6b9bd830e38c978409"
|
||||||
|
|
||||||
"@babel/parser@^7.1.0":
|
"@babel/parser@^7.1.0":
|
||||||
version "7.1.0"
|
version "7.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.0.tgz#a7cd42cb3c12aec52e24375189a47b39759b783e"
|
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.0.tgz#a7cd42cb3c12aec52e24375189a47b39759b783e"
|
||||||
|
@ -581,7 +585,7 @@
|
||||||
invariant "^2.2.0"
|
invariant "^2.2.0"
|
||||||
lodash "^4.17.5"
|
lodash "^4.17.5"
|
||||||
|
|
||||||
"@babel/traverse@^7.1.0":
|
"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0":
|
||||||
version "7.1.0"
|
version "7.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.1.0.tgz#503ec6669387efd182c3888c4eec07bcc45d91b2"
|
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.1.0.tgz#503ec6669387efd182c3888c4eec07bcc45d91b2"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -1022,6 +1026,17 @@ babel-code-frame@^6.26.0:
|
||||||
esutils "^2.0.2"
|
esutils "^2.0.2"
|
||||||
js-tokens "^3.0.2"
|
js-tokens "^3.0.2"
|
||||||
|
|
||||||
|
babel-eslint@^10.0.1:
|
||||||
|
version "10.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.1.tgz#919681dc099614cd7d31d45c8908695092a1faed"
|
||||||
|
dependencies:
|
||||||
|
"@babel/code-frame" "^7.0.0"
|
||||||
|
"@babel/parser" "^7.0.0"
|
||||||
|
"@babel/traverse" "^7.0.0"
|
||||||
|
"@babel/types" "^7.0.0"
|
||||||
|
eslint-scope "3.7.1"
|
||||||
|
eslint-visitor-keys "^1.0.0"
|
||||||
|
|
||||||
babel-loader@^8.0.2:
|
babel-loader@^8.0.2:
|
||||||
version "8.0.2"
|
version "8.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.0.2.tgz#2079b8ec1628284a929241da3d90f5b3de2a5ae5"
|
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.0.2.tgz#2079b8ec1628284a929241da3d90f5b3de2a5ae5"
|
||||||
|
@ -2273,6 +2288,13 @@ eslint-plugin-standard@^3.0.1:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.1.0.tgz#2a9e21259ba4c47c02d53b2d0c9135d4b1022d47"
|
resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.1.0.tgz#2a9e21259ba4c47c02d53b2d0c9135d4b1022d47"
|
||||||
|
|
||||||
|
eslint-scope@3.7.1:
|
||||||
|
version "3.7.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
|
||||||
|
dependencies:
|
||||||
|
esrecurse "^4.1.0"
|
||||||
|
estraverse "^4.1.1"
|
||||||
|
|
||||||
eslint-scope@^4.0.0:
|
eslint-scope@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172"
|
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue