Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions .eslintrc.js

This file was deleted.

7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": true,
"arrowParens": "avoid",
"printWidth": 120,
"bracketSpacing": true,
"trailingComma": "none"
}
24 changes: 24 additions & 0 deletions ENVIRONMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

## Environment variables

| ENV | type | default | required | notes |
| ---------------------------------- | ----------------- | ---------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
| FW_${prefix}DB_CONN_OPTIONS | unknown (envJSON) | | | JSON string with connection options See https://github.com/mysqljs/mysql#connection-options for all possible options |
| FW_${prefix}DB_HOST | string | localhost | | |
| FW_${prefix}DB_NAME | string | ${DB_USER} | | |
| FW_${prefix}DB_PASSWORD | string | | | |
| FW_${prefix}DB_PASSWORD_FILE | string | | | |
| FW_${prefix}DB_PORT | integer | 3306 | | |
| FW_${prefix}DB_USER | string | | * | |
| FW_DB_USE_READ_COMMITTED_ISOLATION | boolean | false | | |

## @fluidware-it/saddlebag@0.3.0

| ENV | type | default | required | notes |
| ---------------------------- | -------- | ----------------------- | -------- | -------- |
| FW_LOGGER_ISO_TIMESTAMP | boolean | false | | |
| FW_LOGGER_LEVEL | string | info | | |
| FW_LOGGER_NAME | string | _function_ | | |
| FW_LOGGER_REDACT_KEYS | string[] | | | |
| FW_LOGGER_SEVERITY_AS_STRING | boolean | false | | |
| npm_package_name | string | @fluidware-it/saddlebag | | |
185 changes: 185 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
* Copyright Fluidware srl
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import globals from 'globals';
import nodePlugin from 'eslint-plugin-n';
import yalhPlugin from 'eslint-plugin-yet-another-license-header';
import pluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

const defaultLicense = `
/*
* Copyright Fluidware srl
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
`;

const baseConfig = tseslint.config(
{
ignores: ['**/.nx/**', '**/build/**', '**/coverage/**', '**/dist/**', '**/node_modules/**']
},
pluginPrettierRecommended,
{
files: ['**/*.{js,ts,mjs}'],
plugins: {
'yet-another-license-header': yalhPlugin,
node: nodePlugin
},
extends: [
eslint.configs.recommended
// nodePlugin.configs['flat/recommended'],
],
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.node
}
},
settings: {
node: {
tryExtensions: ['.js', '.json', '.node', '.ts', '.tsx']
}
},
rules: {
complexity: ['error', 8],
'no-console': 'error',
quotes: ['error', 'single', { avoidEscape: true }],
eqeqeq: ['error', 'smart'],
'prefer-rest-params': 'off',
'yet-another-license-header/header': [
'error',
{
header: defaultLicense,
allowedHeaderPatterns: []
}
],
'no-unused-vars': 'error',
'node/no-deprecated-api': 'error'
}
},

// TypeScript strict rules
{
files: ['**/*.ts'],
plugins: {
'@typescript-eslint': tseslint.plugin
},
// turn on when we can check types
// extends: [...tseslint.configs.recommendedTypeChecked],
extends: [...tseslint.configs.recommended],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true
}
},
rules: {
// 'node/no-missing-import': 'off',

// things that should be repaired
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/no-unsafe-function-type': 'warn',
'@typescript-eslint/no-empty-object-type': 'warn',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],

// old rules
// this is a replacement for the deprecated ban-types rules
'@typescript-eslint/no-restricted-types': [
'warn',
{
types: {
Function: 'fix'
}
}
],
// TODO: fix inheritance
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'memberLike',
modifiers: ['private', 'protected'],
format: ['camelCase'],
leadingUnderscore: 'require'
}
],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-inferrable-types': ['error', { ignoreProperties: true }],
'@typescript-eslint/no-empty-function': ['off'],
'@typescript-eslint/no-shadow': ['warn'],
'prefer-rest-params': 'off',
'@typescript-eslint/explicit-member-accessibility': [
'warn',
{
overrides: {
// `constructor` is public by default.
constructors: 'no-public'
}
}
]
}
},

// Test files have relaxed rules
{
files: ['**/test/**/*.ts', '**/*.test.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/explicit-member-accessibility': 'off',
'no-empty': 'off'
}
},

// ESM files
{
files: ['**/*.mjs'],
languageOptions: {
sourceType: 'module'
}
}
);

export default baseConfig;
18 changes: 17 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
/*
* Copyright Fluidware srl
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverage: true,
reporters: ['default']
reporters: ['default'],
roots: ['./tests']
};
Loading
Loading