Skip to content

Commit

Permalink
Merge pull request #32 from UN-OCHA/HPC-9504
Browse files Browse the repository at this point in the history
HPC-9504: Upgrade to ESLint 9
  • Loading branch information
Pl217 authored Sep 5, 2024
2 parents 37832ad + b8c0ee0 commit 31a9874
Show file tree
Hide file tree
Showing 7 changed files with 799 additions and 799 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @UN-OCHA/hpc-js-reviewers
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Documentation for all configuration options:
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'monthly'
time: '11:00'
timezone: 'Europe/Zurich'
open-pull-requests-limit: 10
reviewers:
- '@UN-OCHA/hpc-js-reviewers'
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run lint-staged
lint-staged
154 changes: 154 additions & 0 deletions eslint.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
const globals = require('globals');
const eslint = require('@eslint/js');
const eslintConfigPrettier = require('eslint-config-prettier');
const eslintPluginUnicorn = require('eslint-plugin-unicorn');
const tseslint = require('typescript-eslint');

module.exports = tseslint.config(
{
languageOptions: {
ecmaVersion: 2024,
sourceType: 'commonjs',
globals: {
...globals.node,
},
},
},
eslint.configs.recommended,
eslintConfigPrettier,
...tseslint.configs.recommended,
{
rules: {
'no-constant-condition': [
'error',
{
checkLoops: false,
},
],
curly: 'error',
eqeqeq: 'error',
'no-else-return': 'error',
'no-lonely-if': 'error',
'no-multi-assign': ['error', { ignoreNonDeclaration: true }],
'no-unneeded-ternary': 'error',
'no-useless-concat': 'error',
'prefer-template': 'error',
'capitalized-comments': [
'warn',
'always',
{
ignoreConsecutiveComments: true,
ignorePattern: 'prettier',
},
],
'require-await': 'error',
},
},
{
files: ['**/*.{js,jsx}'],
rules: {
'no-bitwise': 'error',
'no-case-declarations': 'off',
'no-unused-vars': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
},
},
{
files: ['**/*.{ts,tsx}'],
...eslintPluginUnicorn.configs['flat/recommended'],
rules: {
/**
* There is a conflict between ESLint's `array-callback-return` rule
* and unicorn plugin `no-useless-undefined` rule
*
* https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-undefined.md#conflict-with-eslint-array-callback-return-rule
*/
'array-callback-return': ['error', { allowImplicit: true }],
'no-unused-vars': 'off',
'unicorn/consistent-destructuring': 'error',
'unicorn/consistent-function-scoping': 'off',
'unicorn/expiring-todo-comments': 'off',
'unicorn/explicit-length-check': 'off',
'unicorn/filename-case': 'off',
'unicorn/no-array-reduce': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-await-expression-member': 'off',
'unicorn/no-negated-condition': 'off',
'unicorn/no-nested-ternary': 'off',
'unicorn/no-null': 'off',
'unicorn/number-literal-case': 'off',
'unicorn/prefer-code-point': 'off',
'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
'unicorn/prefer-number-properties': 'off',
'unicorn/prefer-string-slice': 'off',
'unicorn/prefer-switch': 'off',
'unicorn/prefer-ternary': 'off',
'unicorn/prefer-top-level-await': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/switch-case-braces': 'off',
'unicorn/text-encoding-identifier-case': 'off',
// Note: you must disable the base rules, as they can report incorrect errors
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/consistent-generic-constructors': 'error',
'@typescript-eslint/consistent-type-imports': [
'error',
{ fixStyle: 'inline-type-imports' },
],
'@typescript-eslint/prefer-nullish-coalescing': [
'error',
{
ignoreConditionalTests: true,
ignoreMixedLogicalExpressions: true,
},
],
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-var-requires': 'warn',
'@typescript-eslint/no-namespace': 'warn',
'@typescript-eslint/no-empty-object-type': 'warn',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variableLike',
format: ['camelCase'],
},
{
selector: 'variable',
modifiers: ['const'],
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
},
{
selector: 'variable',
types: ['boolean'],
format: ['PascalCase'],
prefix: ['is', 'should', 'has', 'can', 'did', 'does', 'will'],
},
{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
{
selector: 'interface',
format: ['PascalCase'],
},
],
},
}
);
151 changes: 0 additions & 151 deletions eslintrc.base.js

This file was deleted.

Loading

0 comments on commit 31a9874

Please sign in to comment.