This is exactly the same question posed in TS1128: Declaration or statement expected (end of file), but that question never received an answer.
I'm writing a NodeJS/JavaScript/Keystone project. My WebStorm IDE is indicating that I have an error in my code (this is at the end of the file):
I have tried successively commenting out/removing one section of code at a time, until I have nothing left. Only if I remove all the code does the error goes away.
I have no idea where the error is coming from. All the brackets/parentheses seem to match. I also don't know whether this is a TypeScript error, an ESLint error or something else.
The code compiles, but the project is no longer functioning correctly, and I'm wondering if the fact that an error is indicated is pointing to some underlying problem that is causing the project to fail.
The code for this file is:
import { Keystone } from '@keystonejs/keystone';
import { GraphQLApp } from '@keystonejs/app-graphql';
import { AdminUIApp } from '@keystonejs/app-admin-ui';
import { StaticApp } from '@keystonejs/app-static';
import { LocalFileAdapter } from '@keystonejs/file-adapters';
import { IframelyOEmbedAdapter } from '@keystonejs/oembed-adapters';
import { MongooseAdapter } from '@keystonejs/adapter-mongoose';
import { KnexAdapter } from '@keystonejs/adapter-knex';
import { PasswordAuthStrategy } from '@keystonejs/auth-password';
import lists from './lists';
import checkArticlePublishDates from './jobs/checkArticlePublishDates';
import log from './util/log';
import seedDb from './util/seedDb';
require('dotenv').config();
let authStrategy;
const PROJECT_NAME = process.env.PROJECT_NAME;
const iframelyAdapter = new IframelyOEmbedAdapter({
apiKey: process.env.IFRAMELY_KEY
});
const staticPath = 'public';
const staticRoute = '';
const imageFileAdapter = new LocalFileAdapter({
src: `${staticPath}/images`,
path: `${staticRoute}/images`
});
const keystone = new Keystone({
name: PROJECT_NAME,
adapter: new MongooseAdapter()
});
const createAuth = () => {
authStrategy = keystone.createAuthStrategy({
type: PasswordAuthStrategy,
list: 'User',
config: {
identityField: 'username', // default: 'email'
secretField: 'password' // default: 'password'
}
});
};
const createLists = () => lists(keystone, { imageFileAdapter, iframelyAdapter });
const setupCronJobs = async () => {
const checkPub = await checkArticlePublishDates(keystone);
};
const boot = async () => {
createLists();
createAuth();
await keystone.prepare({
cors: { origin: true, credentials: true }
});
await setupCronJobs();
};
boot();
export default {
keystone,
apps: [
new GraphQLApp(),
new AdminUIApp({
adminPath: '/admin',
hooks: require.resolve('./admin/'),
authStrategy,
enableDefaultRoute: true
}),
new StaticApp({
path: '/',
src: 'public',
fallback: 'index.html'
})
]
};
My .eslintrc file is
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true
}
},
"extends": [
"eslint:recommended",
"prettier",
"plugin:react/recommended",
],
"plugins": [
"prettier",
"react",
"react-hooks"
],
"env": {
"es6": true,
"node": true,
"mocha": true,
"browser": true
},
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"react/prop-types": 1,
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"react/no-unescaped-entities": "warn",
"react/no-find-dom-node": 0,
"comma-dangle": ["error", "never"],
"global-require": 0
}
}
and my tsconfig.json file is
{
"compilerOptions": {
"target": "ES6",
"lib": [
"esnext",
"dom"
],
"skipLibCheck": true,
"outDir": "tsout",
"strict": false,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"sourceMap": true,
"alwaysStrict": true,
"jsx": "react"
},
"exclude": [
"node_modules"
]
}
