Skip to content

Commit be8681a

Browse files
author
Bruno Besson
committed
xxx
1 parent 2c6dd37 commit be8681a

9 files changed

+135
-73
lines changed

.eslintrc.cjs

+55-41
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,71 @@
11
module.exports = {
2+
root: true,
3+
extends: ['eslint:recommended'],
24
env: {
35
node: true,
46
es2022: true,
57
},
6-
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
7-
extends: [
8-
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
9-
'plugin:@typescript-eslint/recommended-requiring-type-checking',
10-
'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
11-
'plugin:node/recommended',
12-
'plugin:security/recommended',
13-
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
14-
],
158
parserOptions: {
169
ecmaVersion: 'latest',
17-
project: './tsconfig.eslint.json',
18-
sourceType: 'module', // Allows for the use of imports,
19-
},
20-
rules: {
21-
'node/no-extraneous-import': ['error', { allowModules: ['pino'] }],
22-
'node/no-missing-import': 'off',
23-
'node/no-unpublished-import': ['error', { allowModules: ['type-fest'] }],
24-
'node/no-unsupported-features/es-syntax': 'off',
25-
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true, destructuredArrayIgnorePattern: '^_' }],
26-
'@typescript-eslint/camelcase': 'off',
27-
'@typescript-eslint/explicit-function-return-type': 'error',
28-
'@typescript-eslint/explicit-member-accessibility': ['error', { overrides: { constructors: 'no-public' } }],
10+
sourceType: 'module',
2911
},
3012
overrides: [
3113
{
32-
files: ['./**/*.ts]'],
33-
rules: {
34-
'@typescript-eslint/no-throw-literal': 'error',
14+
files: ['./**/*.ts'],
15+
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
16+
extends: [
17+
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
18+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
19+
'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
20+
'plugin:node/recommended',
21+
'plugin:security/recommended',
22+
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
23+
],
24+
parserOptions: {
25+
ecmaVersion: 'latest',
26+
project: './tsconfig.eslint.json',
27+
sourceType: 'module', // Allows for the use of imports,
3528
},
36-
},
37-
{
38-
files: ['test/**/*.ts'],
39-
plugins: ['jest'],
40-
extends: ['plugin:jest/recommended'],
4129
rules: {
42-
'node/no-unpublished-import': 'off',
43-
'node/no-extraneous-import': 'off',
44-
'@typescript-eslint/unbound-method': 'off',
45-
'jest/unbound-method': 'error',
30+
'node/no-extraneous-import': ['error', { allowModules: ['pino'] }],
31+
'node/no-missing-import': 'off',
32+
'node/no-unpublished-import': ['error', { allowModules: ['type-fest'] }],
33+
'node/no-unsupported-features/es-syntax': 'off',
34+
'@typescript-eslint/no-unused-vars': [
35+
'error',
36+
{ ignoreRestSiblings: true, destructuredArrayIgnorePattern: '^_' },
37+
],
38+
'@typescript-eslint/camelcase': 'off',
39+
'@typescript-eslint/explicit-function-return-type': 'error',
40+
'@typescript-eslint/explicit-member-accessibility': ['error', { overrides: { constructors: 'no-public' } }],
4641
},
47-
},
48-
],
49-
settings: {
50-
'import/resolvers': {
51-
typescript: {
52-
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
53-
project: '.',
42+
overrides: [
43+
{
44+
files: ['./**/*.ts]'],
45+
rules: {
46+
'@typescript-eslint/no-throw-literal': 'error',
47+
},
48+
},
49+
{
50+
files: ['test/**/*.ts'],
51+
plugins: ['jest'],
52+
extends: ['plugin:jest/recommended'],
53+
rules: {
54+
'node/no-unpublished-import': 'off',
55+
'node/no-extraneous-import': 'off',
56+
'@typescript-eslint/unbound-method': 'off',
57+
'jest/unbound-method': 'error',
58+
},
59+
},
60+
],
61+
settings: {
62+
'import/resolvers': {
63+
typescript: {
64+
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
65+
project: '.',
66+
},
67+
},
5468
},
5569
},
56-
},
70+
],
5771
};

src/db/migrations/20210506103300_create_schema.ts renamed to src/db/migrations/20210506103300_create_schema.mjs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import type { Knex } from 'knex';
2-
31
const schema = process.env['DB_SCHEMA'] || 'public';
42

5-
export function up(db: Knex): Knex.SchemaBuilder {
3+
/**
4+
* @param {import('knex').Knex} db
5+
* @returns {import('knex').Knex.SchemaBuilder}
6+
*/
7+
export function up(db) {
68
return db.schema
79
.withSchema(schema)
810
.createTable('users', (table) => {
@@ -37,6 +39,10 @@ export function up(db: Knex): Knex.SchemaBuilder {
3739
});
3840
}
3941

40-
export function down(db: Knex): Knex.SchemaBuilder {
42+
/**
43+
* @param {import('knex').Knex} db
44+
* @returns {import('knex').Knex.SchemaBuilder}
45+
*/
46+
export function down(db) {
4147
return db.schema.withSchema(schema).dropTable('users').dropTable('activities').dropTable('strava');
4248
}

src/db/migrations/20220802100000_garmin.ts renamed to src/db/migrations/20220802100000_garmin.mjs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import type { Knex } from 'knex';
2-
31
const schema = process.env['DB_SCHEMA'] || 'public';
42

5-
export function up(db: Knex): Knex.SchemaBuilder {
3+
/**
4+
* @param {import('knex').Knex} db
5+
* @returns {import('knex').Knex.SchemaBuilder}
6+
*/
7+
export function up(db) {
68
return db.schema
79
.withSchema(schema)
810
.alterTable('users', (table) => {
@@ -14,7 +16,11 @@ export function up(db: Knex): Knex.SchemaBuilder {
1416
});
1517
}
1618

17-
export function down(db: Knex): Knex.SchemaBuilder {
19+
/**
20+
* @param {import('knex').Knex} db
21+
* @returns {import('knex').Knex.SchemaBuilder}
22+
*/
23+
export function down(db) {
1824
return db.schema
1925
.withSchema(schema)
2026
.alterTable('users', (table) => {

src/db/migrations/20221020000000_decathlon.ts renamed to src/db/migrations/20221020000000_decathlon.mjs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import type { Knex } from 'knex';
2-
31
const schema = process.env['DB_SCHEMA'] || 'public';
42

5-
export function up(db: Knex): Knex.SchemaBuilder {
3+
/**
4+
* @param {import('knex').Knex} db
5+
* @returns {import('knex').Knex.SchemaBuilder}
6+
*/
7+
export function up(db) {
68
return db.schema.withSchema(schema).alterTable('users', (table) => {
79
table.string('decathlon_id');
810
table.string('decathlon_access_token', 4096);
@@ -12,7 +14,11 @@ export function up(db: Knex): Knex.SchemaBuilder {
1214
});
1315
}
1416

15-
export function down(db: Knex): Knex.SchemaBuilder {
17+
/**
18+
* @param {import('knex').Knex} db
19+
* @returns {import('knex').Knex.SchemaBuilder}
20+
*/
21+
export function down(db) {
1622
return db.schema.withSchema(schema).alterTable('users', (table) => {
1723
table.dropColumns(
1824
'decathlon_id',

src/db/migrations/20221104000000_activity_details.ts renamed to src/db/migrations/20221104000000_activity_details.mjs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
import type { Knex } from 'knex';
2-
31
const schema = process.env['DB_SCHEMA'] || 'public';
42

5-
export function up(db: Knex): Knex.SchemaBuilder {
3+
/**
4+
* @param {import('knex').Knex} db
5+
* @returns {import('knex').Knex.SchemaBuilder}
6+
*/
7+
export function up(db) {
68
return db.schema.withSchema(schema).alterTable('activities', (table) => {
79
table.integer('length').nullable();
810
table.integer('duration').nullable();
911
table.integer('height_diff_up').nullable();
1012
});
1113
}
1214

13-
export function down(db: Knex): Knex.SchemaBuilder {
15+
/**
16+
* @param {import('knex').Knex} db
17+
* @returns {import('knex').Knex.SchemaBuilder}
18+
*/
19+
export function down(db) {
1420
return db.schema.withSchema(schema).alterTable('activities', (table) => {
1521
table.dropColumns('length', 'duration', 'height_diff_up');
1622
});

src/db/migrations/20221121000000_polar.ts renamed to src/db/migrations/20221121000000_polar.mjs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import type { Knex } from 'knex';
2-
31
const schema = process.env['DB_SCHEMA'] || 'public';
42

5-
export function up(db: Knex): Knex.SchemaBuilder {
3+
/**
4+
* @param {import('knex').Knex} db
5+
* @returns {import('knex').Knex.SchemaBuilder}
6+
*/
7+
export function up(db) {
68
return db.schema
79
.withSchema(schema)
810
.alterTable('users', (table) => {
@@ -15,7 +17,11 @@ export function up(db: Knex): Knex.SchemaBuilder {
1517
});
1618
}
1719

18-
export function down(db: Knex): Knex.SchemaBuilder {
20+
/**
21+
* @param {import('knex').Knex} db
22+
* @returns {import('knex').Knex.SchemaBuilder}
23+
*/
24+
export function down(db) {
1925
return db.schema
2026
.withSchema(schema)
2127
.alterTable('users', (table) => {
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
import type { Knex } from 'knex';
2-
31
const schema = process.env['DB_SCHEMA'] || 'public';
42

5-
export function up(db: Knex): Knex.SchemaBuilder {
3+
/**
4+
* @param {import('knex').Knex} db
5+
* @returns {import('knex').Knex.SchemaBuilder}
6+
*/
7+
export function up(db) {
68
return db.schema.withSchema(schema).alterTable('polar', (table) => {
79
table.string('webhook_secret', 256).alter({ alterNullable: false, alterType: true });
810
});
911
}
1012

11-
export function down(db: Knex): Knex.SchemaBuilder {
13+
/**
14+
* @param {import('knex').Knex} db
15+
* @returns {import('knex').Knex.SchemaBuilder}
16+
*/
17+
export function down(db) {
1218
// nothing to do
1319
return db.schema.withSchema(schema);
1420
}

src/db/migrations/20230127000000_miniatures.ts renamed to src/db/migrations/20230127000000_miniatures.mjs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
import type { Knex } from 'knex';
2-
31
const schema = process.env['DB_SCHEMA'] || 'public';
42

5-
export function up(db: Knex): Knex.SchemaBuilder {
3+
/**
4+
* @param {import('knex').Knex} db
5+
* @returns {import('knex').Knex.SchemaBuilder}
6+
*/
7+
export function up(db) {
68
return db.schema.withSchema(schema).alterTable('activities', (table) => {
79
table.string('miniature', 28);
810
});
911
}
1012

11-
export function down(db: Knex): Knex.SchemaBuilder {
13+
/**
14+
* @param {import('knex').Knex} db
15+
* @returns {import('knex').Knex.SchemaBuilder}
16+
*/
17+
export function down(db) {
1218
return db.schema.withSchema(schema).alterTable('activities', (table) => {
1319
table.dropColumn('miniature');
1420
});

src/db/migrations/20230221000000_coros.ts renamed to src/db/migrations/20230221000000_coros.mjs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import type { Knex } from 'knex';
2-
31
const schema = process.env['DB_SCHEMA'] || 'public';
42

5-
export function up(db: Knex): Knex.SchemaBuilder {
3+
/**
4+
* @param {import('knex').Knex} db
5+
* @returns {import('knex').Knex.SchemaBuilder}
6+
*/
7+
export function up(db) {
68
return db.schema.withSchema(schema).alterTable('users', (table) => {
79
table.string('coros_id', 256).unique();
810
table.string('coros_access_token', 256);
@@ -11,7 +13,11 @@ export function up(db: Knex): Knex.SchemaBuilder {
1113
});
1214
}
1315

14-
export function down(db: Knex): Knex.SchemaBuilder {
16+
/**
17+
* @param {import('knex').Knex} db
18+
* @returns {import('knex').Knex.SchemaBuilder}
19+
*/
20+
export function down(db) {
1521
return db.schema.withSchema(schema).alterTable('users', (table) => {
1622
table.dropColumns('coros_id', 'coros_access_token', 'coros_expires_at', 'coros_refresh_token');
1723
});

0 commit comments

Comments
 (0)