diff --git a/.eslintrc.json b/.eslintrc.json index 1c51996..7e9640b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,26 +1,73 @@ { "env": { - "browser": true, - "commonjs": true, - "es6": true, - "node": true - }, - "extends": "eslint:recommended", - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" + "es6": true, + "jasmine": true, + "node": true, + "browser": true, + "jest": true }, "parserOptions": { - "ecmaVersion": 2018 + "ecmaVersion": 8 }, "rules": { - "indent": [ - "error", - 4 - ], - "semi": [ - "error", - "always" - ] - } -} \ No newline at end of file + "arrow-body-style": 2, + "arrow-spacing": ["warn", {"before": true, "after": true}], + "brace-style": 2, + "camelcase": [2, {"properties": "never"}], + "complexity": ["error", 5], + "eol-last": "warn", + "eqeqeq": "error", + "func-call-spacing": ["error", "never"], + "global-require": "error", + "handle-callback-err": "warn", + "indent": [1, "tab", {"SwitchCase": 1}], + "key-spacing": ["error", {"beforeColon": false, "afterColon": true}], + "linebreak-style": ["warn", "unix"], + "max-depth": ["error", 3], + "max-len": ["warn", { "code": 120, "tabWidth": 4 }], + "max-lines": ["warn", 150], + "max-lines-per-function": ["error", 20], + "max-nested-callbacks": ["error", 4], + "max-params": ["error", 5], + "max-statements": ["error", 20], + "no-cond-assign": 2, + "no-dupe-args": "error", + "no-dupe-keys": "error", + "no-duplicate-case": "error", + "no-empty": "warn", + "no-empty-function": 2, + "no-multiple-empty-lines": "warn", + "no-extra-parens": 2, + "no-func-assign": 2, + "no-irregular-whitespace": 2, + "no-magic-numbers": [1, {"ignore": [-1, 0, 1]}], + "no-multi-spaces": 1, + "no-multi-str": 1, + "no-unexpected-multiline": 2, + "no-unreachable": 2, + "no-self-assign": 2, + "no-trailing-spaces": 1, + "no-undef": 2, + "no-unused-vars": 1, + "no-var": 2, + "prefer-arrow-callback": 1, + "prefer-const": 2, + "prefer-template": "error", + "quotes": [1, "single"], + "semi": [1, "never"], + "space-before-blocks": ["error", { "functions": "always", "keywords": "always", "classes": "always" }], + "space-before-function-paren": [2, "never"], + "strict": [2, "global"], + "yoda": 2 + }, + "overrides": [{ + "files": [ "*.test.js", "*.spec.js", "sqlite-async.js" ], + "rules": { + "global-require": "off", + "max-lines-per-function": "off", + "max-lines": "off", + "max-statements": "off", + "no-magic-numbers": "off" + } + }] + } \ No newline at end of file diff --git a/.gitignore b/.gitignore index 40ca3c5..c73fb45 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,7 @@ website.db .vscode # Env variables -.env \ No newline at end of file +.env + +# Database +*.db \ No newline at end of file diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..3164d3d --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,33 @@ +{ + "line-length": false, + "no-inline-html": { + "allowed_elements": [ + "a", "br" + ] + }, + "header-increment": true, + "ul-style": { + "style": "dash" + }, + "ul-start-left": true, + "no-trailing-spaces": { + "br_spaces": 0 + }, + "no-hard-tabs": true, + "no-reversed-links": true, + "no-multiple-blanks": true, + "no-missing-space-atx": true, + "no-multiple-space-atx": true, + "blanks-around-headers": true, + "header-start-left": true, + "no-duplicate-header": true, + "single-h1": true, + "blanks-around-fences": true, + "blanks-around-lists": true, + "no-bare-urls": true, + "no-space-in-emphasis": true, + "no-space-in-code": true, + "no-space-in-links": true, + "fenced-code-language": true + } + \ No newline at end of file diff --git a/faq.db b/faq.db deleted file mode 100644 index 741b8ca..0000000 Binary files a/faq.db and /dev/null differ diff --git a/jest-test.config.js b/jest-test.config.js new file mode 100644 index 0000000..342685c --- /dev/null +++ b/jest-test.config.js @@ -0,0 +1,19 @@ +'use strict' + +module.exports = { + displayName: 'test', + verbose: true, + collectCoverage: true, + coverageThreshold: { + global: { + branches: 0, + functions: 0, + lines: 0, + statements: 0 + } + }, + testPathIgnorePatterns: [ + '/node_modules/', + '/__tests__/fixtures/', + ] +} \ No newline at end of file diff --git a/jsdoc.conf b/jsdoc.conf new file mode 100644 index 0000000..86de13a --- /dev/null +++ b/jsdoc.conf @@ -0,0 +1,21 @@ +{ + "tags": { + "allowUnknownTags": true, + "dictionaries": ["jsdoc","closure"] + }, + "source": { + "include": [ "." ], + "exclude": [ "node_modules" ], + "includePattern": ".+\\.js(doc|x)?$", + "excludePattern": "(^|\\/|\\\\)_" + }, + "plugins": ["jsdoc-route-plugin"], + "templates": { + "cleverLinks": false, + "monospaceLinks": false + }, + "opts": { + "destination": "docs/jsdoc", + "recurse": true + } +} \ No newline at end of file diff --git a/package.json b/package.json index f4c0011..f76ed86 100644 --- a/package.json +++ b/package.json @@ -2,22 +2,55 @@ "name": "faq", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "server.js", + "engines": { + "node": "12.x" + }, "scripts": { - "lint": "eslint ./", - "start": "nodemon server.js" + "start": "nodemon server.js", + "acceptance": "jest --coverage --detectOpenHandles", + "jsdoc": "node_modules/.bin/jsdoc -c jsdoc.conf", + "linter": "node_modules/.bin/eslint .", + "test": "jest --coverage --detectOpenHandles", + "unit": "node_modules/.bin/jest --coverage --runInBand tests/unit/" + }, + "jest": { + "projects": [ + "/jest-test.config.js" + ] }, - "keywords": [], "author": "", "license": "ISC", "dependencies": { - "dotenv": "^8.1.0", - "koa": "^2.8.2", + "bcrypt": "^3.0.6", + "bcrypt-promise": "^2.0.0", + "dotenv": "^8.2.0", + "fs-extra": "^7.0.1", + "handlebars": "^4.4.2", + "koa": "^2.10.0", + "koa-body": "^4.0.8", + "koa-bodyparser": "^4.2.1", "koa-router": "^7.4.0", + "koa-session": "^5.10.1", + "koa-static": "^5.0.0", + "koa-views": "^6.1.5", + "markdown": "^0.5.0", + "markdownlint-cli": "^0.18.0", + "mime-types": "^2.1.22", + "remark-cli": "^7.0.0", + "remark-lint": "^6.0.5", + "remark-preset-lint-markdown-style-guide": "^2.1.3", + "remark-preset-lint-recommended": "^3.0.3", "sqlite-async": "^1.0.12" }, "devDependencies": { - "eslint": "^6.5.1", - "nodemon": "^1.19.3" + "eslint": "^5.15.2", + "handlebars-validate": "^0.1.2", + "http-status-codes": "^1.3.2", + "jest": "^24.1.0", + "jsdoc": "^3.6.3", + "jsdoc-route-plugin": "^0.1.0", + "markdownlint": "^0.17.0", + "nodemon": "^1.19.4" } }