Skip to content

Commit ae6aa7e

Browse files
authored
Merge pull request #128 from DEFRA/413968
Switch to ESM
2 parents 78d7c7c + fb6d2c4 commit ae6aa7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2191
-1391
lines changed

.babelrc

Lines changed: 0 additions & 31 deletions
This file was deleted.

.eslintrc.cjs

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
module.exports = {
2+
ignorePatterns: ['.server', '.public', 'src/__fixtures__', 'coverage'],
3+
overrides: [
4+
{
5+
extends: [
6+
'standard',
7+
'plugin:import/recommended',
8+
'plugin:import/typescript',
9+
'plugin:jsdoc/recommended-typescript-flavor',
10+
'plugin:n/recommended',
11+
'plugin:promise/recommended',
12+
'plugin:@typescript-eslint/recommended-type-checked',
13+
'plugin:@typescript-eslint/stylistic-type-checked',
14+
'prettier'
15+
],
16+
env: {
17+
browser: false
18+
},
19+
files: ['**/*.{cjs,js}'],
20+
parser: '@typescript-eslint/parser',
21+
parserOptions: {
22+
ecmaVersion: 'latest',
23+
project: ['./tsconfig.json'],
24+
tsconfigRootDir: __dirname
25+
},
26+
plugins: [
27+
'@typescript-eslint',
28+
'import',
29+
'jsdoc',
30+
'n',
31+
'promise',
32+
'prettier'
33+
],
34+
rules: {
35+
'prettier/prettier': [
36+
'error',
37+
{
38+
endOfLine: 'auto'
39+
}
40+
],
41+
'no-console': 'error',
42+
43+
// Turn off strict type checking rules
44+
'@typescript-eslint/no-unsafe-argument': 'off',
45+
'@typescript-eslint/no-unsafe-assignment': 'off',
46+
'@typescript-eslint/no-unsafe-call': 'off',
47+
'@typescript-eslint/no-unsafe-member-access': 'off',
48+
'@typescript-eslint/no-unsafe-return': 'off',
49+
'@typescript-eslint/unbound-method': [
50+
'error',
51+
{
52+
ignoreStatic: true
53+
}
54+
],
55+
56+
// JSDoc blocks are optional by default
57+
'jsdoc/require-jsdoc': 'off',
58+
59+
// JSDoc @param types are mandatory for JavaScript
60+
'jsdoc/require-param-description': 'off',
61+
'jsdoc/require-param-type': 'off',
62+
'jsdoc/require-param': 'off',
63+
64+
// JSDoc @property description is optional
65+
'jsdoc/require-property-description': 'off',
66+
67+
// JSDoc @returns is optional
68+
'jsdoc/require-returns-description': 'off',
69+
'jsdoc/require-returns-type': 'off',
70+
'jsdoc/require-returns': 'off',
71+
72+
// Check for mandatory file extensions
73+
// https://nodejs.org/api/esm.html#mandatory-file-extensions
74+
'import/extensions': ['error', 'always', { ignorePackages: true }],
75+
76+
// Skip rules handled by TypeScript compiler
77+
'import/default': 'off',
78+
'import/namespace': 'off',
79+
'n/no-extraneous-require': 'off',
80+
'n/no-extraneous-import': 'off',
81+
'n/no-missing-require': 'off',
82+
'n/no-missing-import': 'off'
83+
},
84+
settings: {
85+
'import/parsers': {
86+
'@typescript-eslint/parser': ['.cjs', '.js']
87+
},
88+
'import/resolver': {
89+
node: true,
90+
typescript: true
91+
}
92+
}
93+
},
94+
{
95+
files: ['**/*.js'],
96+
parserOptions: {
97+
sourceType: 'module'
98+
}
99+
},
100+
{
101+
env: {
102+
commonjs: true
103+
},
104+
files: ['**/*.cjs'],
105+
parserOptions: {
106+
sourceType: 'commonjs'
107+
},
108+
rules: {
109+
'@typescript-eslint/no-var-requires': 'off'
110+
}
111+
},
112+
{
113+
env: {
114+
browser: true,
115+
node: false
116+
},
117+
files: ['src/client/**/*.js']
118+
},
119+
{
120+
env: {
121+
'jest/globals': true
122+
},
123+
extends: [
124+
'plugin:jest-formatting/recommended',
125+
'plugin:jest/recommended',
126+
'plugin:jest/style'
127+
],
128+
files: ['**/*.test.{cjs,js}', '**/__mocks__/**'],
129+
plugins: ['jest'],
130+
rules: {
131+
// Allow Jest to assert on mocked unbound methods
132+
'@typescript-eslint/unbound-method': 'off',
133+
'jest/unbound-method': 'error'
134+
}
135+
}
136+
],
137+
root: true
138+
}
139+
140+
/**
141+
* @import { ESLint } from 'eslint'
142+
*/

.eslintrc.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.config.*
2+
*.test.*
3+
__fixtures__
4+
test-helpers

.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
tabWidth: 2,
33
semi: false,
44
singleQuote: true,

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ ARG PORT
3838
ENV PORT ${PORT}
3939
EXPOSE ${PORT}
4040

41-
CMD [ "node", "./.server" ]
41+
CMD [ "node", "." ]

babel.config.cjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const { NODE_ENV } = process.env
2+
3+
module.exports = {
4+
presets: [
5+
[
6+
'@babel/preset-env',
7+
{
8+
modules: NODE_ENV === 'test' ? 'auto' : false,
9+
targets: {
10+
node: '20'
11+
}
12+
}
13+
]
14+
],
15+
plugins: [
16+
[
17+
'module-resolver',
18+
{
19+
root: ['./'],
20+
alias: {
21+
'~': '.'
22+
}
23+
}
24+
]
25+
],
26+
env: {
27+
test: {
28+
plugins: ['babel-plugin-transform-import-meta']
29+
}
30+
}
31+
}

jest-mongodb-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
mongodbMemoryServerOptions: {
33
binary: {
44
skipMD5: true

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
rootDir: '.',
33
verbose: true,
44
resetModules: true,

jsconfig.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
{
2-
"compilerOptions": {
3-
"target": "es2020",
4-
"baseUrl": "./",
5-
"paths": {
6-
"~/*": ["./*"]
7-
}
8-
},
9-
"exclude": ["node_modules", "build"]
2+
"extends": "tsconfig.json"
103
}

0 commit comments

Comments
 (0)