From 55b389af51a8634c3f70a33f8dc020982342e090 Mon Sep 17 00:00:00 2001 From: SimeonC <1085899+SimeonC@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:37:24 +0900 Subject: [PATCH] feat: allow `_destroy` as a property The `_destroy: true` property is used as a special key in monolith/ruby-on-rails APIs to indicate that the sub-record should be destroyed so we should allow this specific exception. --- .prettierignore | 1 + packages/eslint-config/src/rules/namingConvention.ts | 9 +++++++++ .../tests/namingConvention.ts/variables.tsx | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/.prettierignore b/.prettierignore index 30e60913..592e54f3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -11,3 +11,4 @@ dist .prettierignore styleguide CHANGELOG.md +.all-contributorsrc \ No newline at end of file diff --git a/packages/eslint-config/src/rules/namingConvention.ts b/packages/eslint-config/src/rules/namingConvention.ts index 4c9dd012..f3bb675e 100644 --- a/packages/eslint-config/src/rules/namingConvention.ts +++ b/packages/eslint-config/src/rules/namingConvention.ts @@ -111,6 +111,15 @@ export const namingRules: Linter.RulesRecord = { match: false, }, }, + { + selector: ['property', 'parameterProperty'], + format: null, + types: ['boolean'], + filter: { + regex: '^_destroy(_|$)', // `_destroy` and `_destroy_*` is used in monolith APIs as a convention + match: true, + }, + }, { selector: ['property', 'parameterProperty'], format: ['camelCase', 'PascalCase', 'snake_case', 'UPPER_CASE'], diff --git a/packages/eslint-config/tests/namingConvention.ts/variables.tsx b/packages/eslint-config/tests/namingConvention.ts/variables.tsx index 420244cd..534af90e 100644 --- a/packages/eslint-config/tests/namingConvention.ts/variables.tsx +++ b/packages/eslint-config/tests/namingConvention.ts/variables.tsx @@ -11,3 +11,12 @@ function SomeComponent({ icon: Icon, command }) { const { other: Other } = command; const iconComponentRef = null; } + +/** _destroy: true special property */ +saveValue({ id: 'id', _destroy: true }); +cy.wait('@monolithSettings_PUT_/sections/1') + .its('request.body') + .should('deep.equal', { + name: 'section 1', + _destroy_background_image: true, + });