From 31ac6d3861dbafdfc1e5594d01c9f4f978c91522 Mon Sep 17 00:00:00 2001 From: Fabian Hiller Date: Fri, 20 Oct 2023 13:36:02 -0400 Subject: [PATCH] Restructure ESLint config and update changelog --- library/.eslintrc.cjs | 49 +++++++++++++++++++++++++------------------ library/CHANGELOG.md | 1 + 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/library/.eslintrc.cjs b/library/.eslintrc.cjs index 20b7bc255..0b59fdf21 100644 --- a/library/.eslintrc.cjs +++ b/library/.eslintrc.cjs @@ -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 }, }; diff --git a/library/CHANGELOG.md b/library/CHANGELOG.md index 55af6ad20..ec36c592f 100644 --- a/library/CHANGELOG.md +++ b/library/CHANGELOG.md @@ -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)