Skip to content

Commit

Permalink
xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Besson committed Apr 11, 2023
1 parent 2c6dd37 commit be8681a
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 73 deletions.
96 changes: 55 additions & 41 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,57 +1,71 @@
module.exports = {
root: true,
extends: ['eslint:recommended'],
env: {
node: true,
es2022: true,
},
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:node/recommended',
'plugin:security/recommended',
'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.
],
parserOptions: {
ecmaVersion: 'latest',
project: './tsconfig.eslint.json',
sourceType: 'module', // Allows for the use of imports,
},
rules: {
'node/no-extraneous-import': ['error', { allowModules: ['pino'] }],
'node/no-missing-import': 'off',
'node/no-unpublished-import': ['error', { allowModules: ['type-fest'] }],
'node/no-unsupported-features/es-syntax': 'off',
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true, destructuredArrayIgnorePattern: '^_' }],
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-member-accessibility': ['error', { overrides: { constructors: 'no-public' } }],
sourceType: 'module',
},
overrides: [
{
files: ['./**/*.ts]'],
rules: {
'@typescript-eslint/no-throw-literal': 'error',
files: ['./**/*.ts'],
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:node/recommended',
'plugin:security/recommended',
'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.
],
parserOptions: {
ecmaVersion: 'latest',
project: './tsconfig.eslint.json',
sourceType: 'module', // Allows for the use of imports,
},
},
{
files: ['test/**/*.ts'],
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
'node/no-unpublished-import': 'off',
'node/no-extraneous-import': 'off',
'@typescript-eslint/unbound-method': 'off',
'jest/unbound-method': 'error',
'node/no-extraneous-import': ['error', { allowModules: ['pino'] }],
'node/no-missing-import': 'off',
'node/no-unpublished-import': ['error', { allowModules: ['type-fest'] }],
'node/no-unsupported-features/es-syntax': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ ignoreRestSiblings: true, destructuredArrayIgnorePattern: '^_' },
],
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-member-accessibility': ['error', { overrides: { constructors: 'no-public' } }],
},
},
],
settings: {
'import/resolvers': {
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
project: '.',
overrides: [
{
files: ['./**/*.ts]'],
rules: {
'@typescript-eslint/no-throw-literal': 'error',
},
},
{
files: ['test/**/*.ts'],
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
'node/no-unpublished-import': 'off',
'node/no-extraneous-import': 'off',
'@typescript-eslint/unbound-method': 'off',
'jest/unbound-method': 'error',
},
},
],
settings: {
'import/resolvers': {
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
project: '.',
},
},
},
},
},
],
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Knex } from 'knex';

const schema = process.env['DB_SCHEMA'] || 'public';

export function up(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function up(db) {
return db.schema
.withSchema(schema)
.createTable('users', (table) => {
Expand Down Expand Up @@ -37,6 +39,10 @@ export function up(db: Knex): Knex.SchemaBuilder {
});
}

export function down(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function down(db) {
return db.schema.withSchema(schema).dropTable('users').dropTable('activities').dropTable('strava');
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Knex } from 'knex';

const schema = process.env['DB_SCHEMA'] || 'public';

export function up(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function up(db) {
return db.schema
.withSchema(schema)
.alterTable('users', (table) => {
Expand All @@ -14,7 +16,11 @@ export function up(db: Knex): Knex.SchemaBuilder {
});
}

export function down(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function down(db) {
return db.schema
.withSchema(schema)
.alterTable('users', (table) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Knex } from 'knex';

const schema = process.env['DB_SCHEMA'] || 'public';

export function up(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function up(db) {
return db.schema.withSchema(schema).alterTable('users', (table) => {
table.string('decathlon_id');
table.string('decathlon_access_token', 4096);
Expand All @@ -12,7 +14,11 @@ export function up(db: Knex): Knex.SchemaBuilder {
});
}

export function down(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function down(db) {
return db.schema.withSchema(schema).alterTable('users', (table) => {
table.dropColumns(
'decathlon_id',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import type { Knex } from 'knex';

const schema = process.env['DB_SCHEMA'] || 'public';

export function up(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function up(db) {
return db.schema.withSchema(schema).alterTable('activities', (table) => {
table.integer('length').nullable();
table.integer('duration').nullable();
table.integer('height_diff_up').nullable();
});
}

export function down(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function down(db) {
return db.schema.withSchema(schema).alterTable('activities', (table) => {
table.dropColumns('length', 'duration', 'height_diff_up');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Knex } from 'knex';

const schema = process.env['DB_SCHEMA'] || 'public';

export function up(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function up(db) {
return db.schema
.withSchema(schema)
.alterTable('users', (table) => {
Expand All @@ -15,7 +17,11 @@ export function up(db: Knex): Knex.SchemaBuilder {
});
}

export function down(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function down(db) {
return db.schema
.withSchema(schema)
.alterTable('users', (table) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import type { Knex } from 'knex';

const schema = process.env['DB_SCHEMA'] || 'public';

export function up(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function up(db) {
return db.schema.withSchema(schema).alterTable('polar', (table) => {
table.string('webhook_secret', 256).alter({ alterNullable: false, alterType: true });
});
}

export function down(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function down(db) {
// nothing to do
return db.schema.withSchema(schema);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import type { Knex } from 'knex';

const schema = process.env['DB_SCHEMA'] || 'public';

export function up(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function up(db) {
return db.schema.withSchema(schema).alterTable('activities', (table) => {
table.string('miniature', 28);
});
}

export function down(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function down(db) {
return db.schema.withSchema(schema).alterTable('activities', (table) => {
table.dropColumn('miniature');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Knex } from 'knex';

const schema = process.env['DB_SCHEMA'] || 'public';

export function up(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function up(db) {
return db.schema.withSchema(schema).alterTable('users', (table) => {
table.string('coros_id', 256).unique();
table.string('coros_access_token', 256);
Expand All @@ -11,7 +13,11 @@ export function up(db: Knex): Knex.SchemaBuilder {
});
}

export function down(db: Knex): Knex.SchemaBuilder {
/**
* @param {import('knex').Knex} db
* @returns {import('knex').Knex.SchemaBuilder}
*/
export function down(db) {
return db.schema.withSchema(schema).alterTable('users', (table) => {
table.dropColumns('coros_id', 'coros_access_token', 'coros_expires_at', 'coros_refresh_token');
});
Expand Down

0 comments on commit be8681a

Please sign in to comment.