Skip to content

Commit

Permalink
build: eslint updates
Browse files Browse the repository at this point in the history
* Update eslint to latest version
* migrate to flat config
* Add eslint-plugin-n and eslint-plugin-unicorn
  • Loading branch information
jrassa committed Feb 20, 2025
1 parent 1299fa1 commit 8132d86
Show file tree
Hide file tree
Showing 73 changed files with 7,904 additions and 14,572 deletions.
12 changes: 0 additions & 12 deletions .eslintignore

This file was deleted.

112 changes: 0 additions & 112 deletions .eslintrc

This file was deleted.

20 changes: 10 additions & 10 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ module.exports = {

messages: {
topic: 'message.posted',
expireSeconds: 2592000, // default to 30 days,
dismissedTimeSeconds: 604800 // default to 7 days
expireSeconds: 2_592_000, // default to 30 days,
dismissedTimeSeconds: 604_800 // default to 7 days
},

pages: {
Expand Down Expand Up @@ -190,7 +190,7 @@ module.exports = {
file: './src/app/core/access-checker/cache/cache-refresh.job',
interval: '12 hours',
data: {
refresh: 12 * 3600000
refresh: 12 * 3_600_000
}
},
'inactive-user': {
Expand All @@ -199,10 +199,10 @@ module.exports = {
interval: '1 days',
data: {
alertIntervals: [
30 * 86400000, // 30 days
60 * 86400000 // 60 days
30 * 86_400_000, // 30 days
60 * 86_400_000 // 60 days
],
deactivateAfter: 90 * 86400000 // 90 days
deactivateAfter: 90 * 86_400_000 // 90 days
}
}
}
Expand Down Expand Up @@ -237,17 +237,17 @@ module.exports = {
/*
* The maximum time in milliseconds allowed for processing operation on the cursor by a mongo query
*/
maxTimeMS: 30000,
maxTimeMS: 30_000,

/*
* The maximum time in milliseconds allowed for a count operation on the cursor by a mongo search/pagination query
*/
maxCountTimeMS: 5000,

// configures mongo TTL index. Overriding these may require dropping existing index
notificationExpires: 15552000, // 180 days
auditExpires: 15552000, //180 days
feedbackExpires: 15552000, // 180 days
notificationExpires: 15_552_000, // 180 days
auditExpires: 15_552_000, //180 days
feedbackExpires: 15_552_000, // 180 days

/**
* Environment Settings
Expand Down
135 changes: 135 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import eslint from '@eslint/js';
import eslintPluginImport from 'eslint-plugin-import';
import eslintPluginNode from 'eslint-plugin-n';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: [
'src/migrations/sample-migration.ts',
// Ignore artifacts
'.nyc_output/',
'build/',
'coverage/',
'dist/',
'node_modules/',
// IDE/Editor config
'.vscode/'
]
},
eslint.configs.recommended,
tseslint.configs.recommended,
eslintPluginPrettierRecommended,
eslintPluginImport.flatConfigs.recommended,
eslintPluginImport.flatConfigs.typescript,
eslintPluginNode.configs['flat/recommended'],
eslintPluginUnicorn.configs['flat/recommended'],
{
languageOptions: {
globals: {
...globals.builtin,
...globals.node,
...globals.mocha
},
ecmaVersion: 2020,
sourceType: 'module'
},
rules: {
// eslint
eqeqeq: ['error', 'smart'],
'guard-for-in': ['error'],
'no-await-in-loop': ['error'],
'no-console': ['warn'],
'no-else-return': ['error'],
'no-new-wrappers': ['error'],
'no-path-concat': ['warn'],
'no-template-curly-in-string': ['error'],
'no-throw-literal': ['error'],
'no-unused-vars': ['off'], // Disabling in favor of typescript-eslint version
'no-var': ['error'],
'prefer-const': ['error'],
'prefer-destructuring': [
'error',
{
object: false,
array: true
}
],
'prefer-numeric-literals': ['error'],
'prefer-promise-reject-errors': ['error'],
'prefer-rest-params': ['error'],
'prefer-spread': ['error'],
'prefer-template': ['error'],
'require-await': ['error'],
'prettier/prettier': ['error'],
// eslint-plugin-import
'import/order': [
'error',
{
groups: [
['builtin'],
['external'],
['internal', 'parent', 'sibling']
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true
}
}
],
'import/no-unresolved': ['off'],
// eslint-plugin-n
'n/callback-return': ['warn'],
'n/no-missing-import': ['off'],
'n/no-new-require': ['warn'],
'n/no-path-concat': ['warn'],
'n/no-process-exit': ['off'],
// @typescript-eslint
'@typescript-eslint/no-empty-function': ['error'],
'@typescript-eslint/no-unused-vars': ['error'],
// eslint-plugin-unicorn
'unicorn/filename-case': ['off'],
'unicorn/no-anonymous-default-export': ['off'],
'unicorn/no-array-callback-reference': ['off'],
'unicorn/no-null': ['off'],
'unicorn/no-process-exit': ['off'],
'unicorn/no-this-assignment': ['off'],
'unicorn/no-useless-promise-resolve-reject': ['off'],
'unicorn/no-useless-undefined': ['off'],
'unicorn/prefer-event-target': ['off'],
'unicorn/prefer-export-from': ['off'],
'unicorn/prefer-module': ['off'],
'unicorn/prefer-number-properties': ['off'],
'unicorn/prefer-ternary': ['off'],
'unicorn/prefer-top-level-await': ['off'],
'unicorn/prevent-abbreviations': ['off']
}
},
{
files: ['src/dependencies.ts'],
linterOptions: {
reportUnusedDisableDirectives: 'off'
},
rules: {
'unicorn/no-abusive-eslint-disable': ['off']
}
},
{
files: ['src/migrations/**/*'],
rules: {
'n/no-extraneous-import': ['off']
}
},
{
files: ['src/cli/**/*'],
rules: {
'n/hashbang': ['off'],
'n/no-extraneous-require': ['off'],
'@typescript-eslint/no-require-imports': ['off']
}
}
);
Loading

0 comments on commit 8132d86

Please sign in to comment.