Replace javascript config with typescript
This commit is contained in:
parent
3cfcbb1251
commit
75e3f88c9b
|
|
@ -1,18 +0,0 @@
|
||||||
module.exports = {
|
|
||||||
'extends': ['google', 'plugin:react/recommended'],
|
|
||||||
'parser': 'babel-eslint',
|
|
||||||
'env': {
|
|
||||||
'browser': true,
|
|
||||||
},
|
|
||||||
'globals': {
|
|
||||||
'React': true,
|
|
||||||
},
|
|
||||||
'plugins': ['react', 'babel'],
|
|
||||||
'rules': {
|
|
||||||
'linebreak-style': 0,
|
|
||||||
'max-len': ['error', 140],
|
|
||||||
'require-jsdoc': 0,
|
|
||||||
'babel/no-invalid-this': 1,
|
|
||||||
'no-invalid-this': 0,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "gotify-ui",
|
"name": "gotify-ui",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.18.0",
|
"axios": "^0.18.0",
|
||||||
|
|
@ -10,29 +10,34 @@
|
||||||
"material-ui-icons": "^1.0.0-beta.36",
|
"material-ui-icons": "^1.0.0-beta.36",
|
||||||
"notifyjs": "^3.0.0",
|
"notifyjs": "^3.0.0",
|
||||||
"prop-types": "^15.6.1",
|
"prop-types": "^15.6.1",
|
||||||
"react": "^16.2.0",
|
"react": "^16.3.2",
|
||||||
"react-dom": "^16.2.0",
|
"react-dom": "^16.3.2",
|
||||||
"react-global-configuration": "^1.2.1",
|
|
||||||
"react-list": "^0.8.8",
|
"react-list": "^0.8.8",
|
||||||
"react-router": "^4.2.0",
|
"react-router": "^4.2.0",
|
||||||
"react-router-dom": "^4.2.2",
|
"react-router-dom": "^4.2.2",
|
||||||
"react-scripts": "1.1.1",
|
"react-scripts-ts": "2.15.1",
|
||||||
"react-timeago": "^3.4.3",
|
"react-timeago": "^3.4.3",
|
||||||
"typeface-roboto": "0.0.54",
|
"typeface-roboto": "0.0.54",
|
||||||
"typeface-roboto-mono": "0.0.54"
|
"typeface-roboto-mono": "0.0.54"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts-ts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts-ts build",
|
||||||
"test": "react-scripts test --env=jsdom",
|
"test": "react-scripts-ts test --env=jsdom",
|
||||||
"lint": "eslint src",
|
"eject": "react-scripts-ts eject",
|
||||||
"eject": "react-scripts eject"
|
"lint": "tslint --project .",
|
||||||
|
"lintfix": "tslint --fix --project ."
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^8.2.2",
|
"@types/notifyjs": "^1.2.30",
|
||||||
"eslint": "^4.18.2",
|
"@types/detect-browser": "^2.0.1",
|
||||||
"eslint-config-google": "^0.9.1",
|
"@types/flux": "^3.1.7",
|
||||||
"eslint-plugin-babel": "^4.1.2",
|
"@types/jest": "^22.2.3",
|
||||||
"eslint-plugin-react": "^7.7.0"
|
"@types/node": "^9.6.5",
|
||||||
|
"@types/react": "^16.3.11",
|
||||||
|
"@types/react-dom": "^16.0.5",
|
||||||
|
"@types/react-list": "^0.8.3",
|
||||||
|
"@types/react-router-dom": "^4.2.6",
|
||||||
|
"typescript": "^2.8.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
|
// tslint:disable:no-console
|
||||||
// In production, we register a service worker to serve assets from local cache.
|
// In production, we register a service worker to serve assets from local cache.
|
||||||
|
|
||||||
// This lets the app load faster on subsequent visits in production, and gives
|
// This lets the app load faster on subsequent visits in production, and gives
|
||||||
// it offline capabilities. However, it also means that developers (and users)
|
// it offline capabilities. However, it also means that developers (and users)
|
||||||
// will only see deployed updates on the "N+1" visit to a page, since previously
|
// will only see deployed updates on the 'N+1' visit to a page, since previously
|
||||||
// cached resources are updated in the background.
|
// cached resources are updated in the background.
|
||||||
|
|
||||||
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
|
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
|
||||||
|
|
@ -21,9 +22,10 @@ const isLocalhost = Boolean(
|
||||||
export default function register() {
|
export default function register() {
|
||||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||||
// The URL constructor is available in all browsers that support SW.
|
// The URL constructor is available in all browsers that support SW.
|
||||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
|
const publicUrl = new URL(
|
||||||
|
process.env.PUBLIC_URL!,
|
||||||
|
window.location.toString()
|
||||||
|
);
|
||||||
if (publicUrl.origin !== window.location.origin) {
|
if (publicUrl.origin !== window.location.origin) {
|
||||||
// Our service worker won't work if PUBLIC_URL is on a different origin
|
// Our service worker won't work if PUBLIC_URL is on a different origin
|
||||||
// from what our page is served on. This might happen if a CDN is used to
|
// from what our page is served on. This might happen if a CDN is used to
|
||||||
|
|
@ -32,7 +34,7 @@ export default function register() {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
const swUrl = `./service-worker.js`;
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||||
|
|
||||||
if (isLocalhost) {
|
if (isLocalhost) {
|
||||||
// This is running on localhost. Lets check if a service worker still exists or not.
|
// This is running on localhost. Lets check if a service worker still exists or not.
|
||||||
|
|
@ -54,49 +56,51 @@ export default function register() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerValidSW(swUrl) {
|
function registerValidSW(swUrl: string) {
|
||||||
if (!window.location.href.match('^([^/]*\\/)(.*\\.js|.*.html|static\\/.*|)$')) {
|
if (!window.location.href.match('^([^/]*\\/)(.*\\.js|.*.html|static\\/.*|)$')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register(swUrl)
|
.register(swUrl)
|
||||||
.then((registration) => {
|
.then(registration => {
|
||||||
registration.onupdatefound = () => {
|
registration.onupdatefound = () => {
|
||||||
const installingWorker = registration.installing;
|
const installingWorker = registration.installing;
|
||||||
installingWorker.onstatechange = () => {
|
if (installingWorker) {
|
||||||
if (installingWorker.state === 'installed') {
|
installingWorker.onstatechange = () => {
|
||||||
if (navigator.serviceWorker.controller) {
|
if (installingWorker.state === 'installed') {
|
||||||
// At this point, the old content will have been purged and
|
if (navigator.serviceWorker.controller) {
|
||||||
// the fresh content will have been added to the cache.
|
// At this point, the old content will have been purged and
|
||||||
// It's the perfect time to display a "New content is
|
// the fresh content will have been added to the cache.
|
||||||
// available; please refresh." message in your web app.
|
// It's the perfect time to display a 'New content is
|
||||||
console.log('New content is available; please refresh.');
|
// available; please refresh.' message in your web app.
|
||||||
} else {
|
console.log('New content is available; please refresh.');
|
||||||
// At this point, everything has been precached.
|
} else {
|
||||||
// It's the perfect time to display a
|
// At this point, everything has been precached.
|
||||||
// "Content is cached for offline use." message.
|
// It's the perfect time to display a
|
||||||
console.log('Content is cached for offline use.');
|
// 'Content is cached for offline use.' message.
|
||||||
|
console.log('Content is cached for offline use.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
console.error('Error during service worker registration:', error);
|
console.error('Error during service worker registration:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkValidServiceWorker(swUrl) {
|
function checkValidServiceWorker(swUrl: string) {
|
||||||
// Check if the service worker can be found. If it can't reload the page.
|
// Check if the service worker can be found. If it can't reload the page.
|
||||||
fetch(swUrl)
|
fetch(swUrl)
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
// Ensure service worker exists, and that we really are getting a JS file.
|
// Ensure service worker exists, and that we really are getting a JS file.
|
||||||
if (
|
if (
|
||||||
response.status === 404 ||
|
response.status === 404 ||
|
||||||
response.headers.get('content-type').indexOf('javascript') === -1
|
response.headers.get('content-type')!.indexOf('javascript') === -1
|
||||||
) {
|
) {
|
||||||
// No service worker found. Probably a different app. Reload the page.
|
// No service worker found. Probably a different app. Reload the page.
|
||||||
navigator.serviceWorker.ready.then((registration) => {
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
registration.unregister().then(() => {
|
registration.unregister().then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
|
@ -115,7 +119,7 @@ function checkValidServiceWorker(swUrl) {
|
||||||
|
|
||||||
export function unregister() {
|
export function unregister() {
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
navigator.serviceWorker.ready.then((registration) => {
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
registration.unregister();
|
registration.unregister();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"outDir": "build/dist",
|
||||||
|
"module": "esnext",
|
||||||
|
"target": "es5",
|
||||||
|
"lib": ["es6", "dom"],
|
||||||
|
"sourceMap": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"jsx": "react",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"rootDir": "src",
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"suppressImplicitAnyIndexErrors": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"allowSyntheticDefaultImports": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"build",
|
||||||
|
"scripts",
|
||||||
|
"acceptance-tests",
|
||||||
|
"webpack",
|
||||||
|
"jest",
|
||||||
|
"src/setupTests.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
|
||||||
|
"jsRules": {
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"no-console": false
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"jsx-boolean-value": false,
|
||||||
|
"no-console": false,
|
||||||
|
"jsx-no-lambda": false
|
||||||
|
},
|
||||||
|
"linterOptions": {
|
||||||
|
"exclude": [
|
||||||
|
"config/**/*.js",
|
||||||
|
"node_modules/**/*.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue