Skip to content

Commit 1240115

Browse files
committed
feat: migrate to typescript
1 parent b2f86cb commit 1240115

File tree

19 files changed

+3522
-1878
lines changed

19 files changed

+3522
-1878
lines changed

.eslintrc.js

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,24 @@
11
module.exports = {
2-
'env': {
3-
'es6': true,
4-
'node': true,
5-
'mocha': true
6-
},
7-
'extends': 'airbnb-base',
8-
'parserOptions': {
9-
'ecmaVersion': 2018,
10-
'sourceType': 'module'
2+
parser: '@typescript-eslint/parser',
3+
plugins: ['@typescript-eslint/eslint-plugin'],
4+
extends: [
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:prettier/recommended',
7+
],
8+
parserOptions: {
9+
ecmaVersion: 2018,
10+
sourceType: 'module',
11+
ecmaFeatures: {
12+
jsx: true,
13+
},
1114
},
12-
'rules': {
13-
'indent': [
14-
'error',
15-
2
16-
],
17-
'linebreak-style': [
18-
'error',
19-
'unix'
20-
],
21-
'quotes': [
22-
'error',
23-
'single'
24-
],
25-
'semi': [
26-
'error',
27-
'never'
28-
],
29-
'import/no-unresolved': 'off',
30-
'no-underscore-dangle': 'off',
31-
'guard-for-in': 'off',
32-
'no-restricted-syntax': 'off',
33-
'no-await-in-loop': 'off',
15+
rules: {
16+
'prettier/prettier': 'error'
3417
},
35-
overrides: [
36-
{
37-
files: ['*-test.js', '*.spec.js'],
38-
rules: {
39-
'no-unused-expressions': 'off',
40-
'func-names': 'off',
41-
'prefer-arrow-callback': 'off'
42-
}
18+
ignorePatterns: ['node_modules', 'lib'],
19+
settings: {
20+
react: {
21+
version: 'detect',
4322
},
44-
{
45-
files: ["examples/**/*.js"],
46-
rules: {
47-
'import/no-extraneous-dependencies': 'off'
48-
}
49-
}
50-
],
51-
globals: {
52-
'expect': true,
53-
'factory': true,
54-
'sandbox': true
55-
}
56-
}
23+
},
24+
};

.gitignore

Lines changed: 121 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,121 @@
1-
node_modules
2-
.DS_store
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# Snowpack dependency directory (https://snowpack.dev/)
45+
web_modules/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
.parcel-cache
78+
79+
# Next.js build output
80+
.next
81+
out
82+
83+
# Nuxt.js build / generate output
84+
.nuxt
85+
dist
86+
87+
# Gatsby files
88+
.cache/
89+
# Comment in the public line in if your project uses Gatsby and not Next.js
90+
# https://nextjs.org/blog/next-9-1#public-directory-support
91+
# public
92+
93+
# vuepress build output
94+
.vuepress/dist
95+
96+
# Serverless directories
97+
.serverless/
98+
99+
# FuseBox cache
100+
.fusebox/
101+
102+
# DynamoDB Local files
103+
.dynamodb/
104+
105+
# TernJS port file
106+
.tern-port
107+
108+
# Stores VSCode versions used for testing VSCode extensions
109+
.vscode-test
110+
111+
# yarn v2
112+
.yarn/cache
113+
.yarn/unplugged
114+
.yarn/build-state.yml
115+
.yarn/install-state.gz
116+
.pnp.*
117+
118+
.DS_store
119+
120+
# build files
121+
/lib

.idea/admin-bro-expressjs.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

@types/express-session/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export {};
2+
3+
declare module "express-session" {
4+
interface SessionData {
5+
adminUser?: unknown;
6+
redirectTo?: string;
7+
}
8+
}

index.js renamed to index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
* meaning that it should have at least an email property.
8989
*/
9090

91-
const Plugin = require('./plugin')
91+
import * as Plugin from "./src/plugin";
9292

93-
module.exports = Plugin
93+
module.exports = Plugin;
94+
export default Plugin;

package.json

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
"description": "This is an official AdminBro plugin which integrates it to expressjs framework",
55
"main": "index.js",
66
"scripts": {
7+
"dev": "rm -rf lib && tsc --watch",
8+
"build": "rm -rf lib && tsc",
79
"simple": "nodemon examples/simple.js",
8-
"test": "./node_modules/.bin/mocha spec/index.js",
9-
"lint": "./node_modules/eslint/bin/eslint.js './examples/**/*.js' './plugin.js'",
10+
"test": "jest --config ./test/jest.json",
11+
"lint": "eslint './**/*.ts'",
12+
"check:all": "yarn lint && yarn build && yarn test",
1013
"release": "semantic-release"
1114
},
1215
"repository": {
@@ -20,7 +23,7 @@
2023
"admin-panel"
2124
],
2225
"author": "Michał Laskowski",
23-
"license": "MIT",
26+
"license": "SEE LICENSE IN LICENSE",
2427
"bugs": {
2528
"url": "https://github.com/SoftwareBrothers/admin-bro-expressjs/issues"
2629
},
@@ -37,28 +40,35 @@
3740
}
3841
},
3942
"devDependencies": {
40-
"@types/express": "^4.17.4",
41-
"@types/mocha": "^7.0.2",
42-
"admin-bro": ">=3.0.0",
43-
"@admin-bro/mongoose": "^1.0.0",
43+
"@admin-bro/mongoose": "^1.1.0",
44+
"@types/express": "^4.16.4",
45+
"@types/express-formidable": "^1.0.4",
46+
"@types/express-serve-static-core": "^4.17.13",
47+
"@types/express-session": "^1.17.3",
48+
"@types/jest": "^26.0.15",
49+
"@types/mongoose": "^5.10.1",
50+
"@typescript-eslint/eslint-plugin": "^4.8.1",
51+
"@typescript-eslint/parser": "^4.8.1",
52+
"admin-bro": "^3.3.1",
4453
"chai": "^4.2.0",
45-
"eslint": "^5.10.0",
46-
"eslint-config-airbnb-base": "^13.1.0",
47-
"eslint-plugin-import": "^2.14.0",
48-
"express": "^4.16.4",
54+
"eslint": "^7.13.0",
55+
"eslint-config-airbnb-base": "^14.2.1",
56+
"eslint-config-prettier": "^6.15.0",
57+
"eslint-plugin-import": "^2.22.1",
58+
"eslint-plugin-prettier": "^3.1.4",
59+
"express": "^4.17.1",
4960
"express-formidable": "^1.2.0",
50-
"express-session": ">=1.15.6",
51-
"mocha": "^5.2.0",
52-
"mongoose": "^5.3.16",
53-
"nodemon": "^1.18.8",
54-
"sinon": "^7.2.3",
55-
"sinon-chai": "^3.3.0",
56-
"semantic-release": "^17.0.7",
61+
"express-session": "^1.17.1",
62+
"husky": "^4.3.0",
63+
"jest": "^26.6.3",
64+
"mongoose": "^5.10.15",
65+
"prettier": "^2.2.0",
66+
"semantic-release": "^17.2.4",
5767
"semantic-release-jira-releases-sb": "^0.7.2",
5868
"semantic-release-slack-bot": "^1.6.2",
59-
"@semantic-release/git": "^9.0.0",
60-
"husky": "^4.2.5",
61-
"@commitlint/cli": "^8.3.5",
62-
"@commitlint/config-conventional": "^8.3.4"
69+
"sinon": "^9.2.1",
70+
"sinon-chai": "^3.5.0",
71+
"ts-jest": "^26.4.4",
72+
"typescript": "^4.1.2"
6373
}
6474
}

0 commit comments

Comments
 (0)