Skip to content

Commit

Permalink
Restructure ESLint config and update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller committed Oct 20, 2023
1 parent 7ce200c commit 31ac6d3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
49 changes: 29 additions & 20 deletions library/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,39 @@ module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import', 'redos-detector'],
rules: {
// Enable rules -----------------------------------------------------------

// Import
'import/extensions': ['error', 'always'], // Require file extensions

// Regexp
'regexp/no-super-linear-move': 'error', // Prevent DoS regexps
'regexp/no-control-character': 'error', // Avoid unneeded regexps characters
'regexp/no-octal': 'error', // Avoid unneeded regexps characters
'regexp/no-standalone-backslash': 'error', // Avoid unneeded regexps characters
'regexp/prefer-escape-replacement-dollar-char': 'error', // Avoid unneeded regexps characters
'regexp/prefer-quantifier': 'error', // Avoid unneeded regexps characters
'regexp/hexadecimal-escape': ['error', 'always'], // Avoid unneeded regexps characters
'regexp/sort-alternatives': 'error', // Avoid unneeded regexps characters
'regexp/require-unicode-regexp': 'error', // /u flag is faster and enables regexp strict mode
'regexp/prefer-regexp-exec': 'error', // Enforce that RegExp#exec is used instead of String#match if no global flag is provided, as exec is faster

// Redos detector
'redos-detector/no-unsafe-regex': ['error', { ignoreError: true }], // Prevent DoS regexps

// Disable rules ----------------------------------------------------------

// Default
'no-duplicate-imports': 'off',

// TypeScript
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-duplicate-imports': 'off',
'import/extensions': ['error', 'always'],

'security/detect-object-injection': 'off', // too many false positives
'security/detect-unsafe-regex': 'off', // too many false positives, see https://github.com/eslint-community/eslint-plugin-security/issues/28 - we use the redos-detector plugin instead
'regexp/no-super-linear-move': 'error', // prevent DoS regexps
'redos-detector/no-unsafe-regex': ['error', { ignoreError: true }], // prevent DoS regexps

// regexp rules not turned on by regexp/recommend
// avoid unneeded regexps characters / style
'regexp/no-control-character': 'error',
'regexp/no-octal': 'error',
'regexp/no-standalone-backslash': 'error',
'regexp/prefer-escape-replacement-dollar-char': 'error',
'regexp/prefer-quantifier': 'error',
'regexp/hexadecimal-escape': ['error', 'always'],
'regexp/sort-alternatives': 'error',

// regexp perf
'regexp/require-unicode-regexp': 'error', // /u flag is faster and enables regexp strict mode
'regexp/prefer-regexp-exec': 'error', // enforce that RegExp#exec is used instead of String#match if no global flag is provided, as exec is faster
// Security
'security/detect-object-injection': 'off', // Too many false positives
'security/detect-unsafe-regex': 'off', // Too many false positives, see https://github.com/eslint-community/eslint-plugin-security/issues/28 - we use the redos-detector plugin instead
},
};
1 change: 1 addition & 0 deletions library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to the library will be documented in this file.

- Change regex of `email` validation (pull request #180)
- Fix types at `brand`, `transform` and `unwrap` method (issue #195)
- Improve security of regular expressions (pull request #202)

## v0.18.0 (September 30, 2023)

Expand Down

0 comments on commit 31ac6d3

Please sign in to comment.