Skip to content

Commit

Permalink
Merge branch 'develop' into M3-8945-update-yup-to-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
bnussman committed Dec 2, 2024
2 parents e2dde35 + 8611b57 commit 1d582ab
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 9 deletions.
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-11337-added-1732714186488.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Added
---

Linter rules for naming convention ([#11337](https://github.com/linode/manager/pull/11337))
45 changes: 36 additions & 9 deletions packages/api-v4/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,42 @@
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/naming-convention": [
"warn",
{
"format": ["camelCase", "UPPER_CASE", "PascalCase"],
"leadingUnderscore": "allow",
"selector": "variable",
"trailingUnderscore": "allow"
},
{
"format": null,
"modifiers": ["destructured"],
"selector": "variable"
},
{
"format": ["camelCase", "PascalCase"],
"selector": "function"
},
{
"format": ["camelCase"],
"leadingUnderscore": "allow",
"selector": "parameter"
},
{
"format": ["PascalCase"],
"selector": "typeLike"
}
],
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/interface-name-prefix": "off",
"no-unused-vars": [
"warn",
{
Expand All @@ -33,15 +69,6 @@
"no-console": "error",
"no-undef-init": "off",
"radix": "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-namespace": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/interface-name-prefix": "off",
"sonarjs/cognitive-complexity": "warn",
"sonarjs/no-duplicate-string": "warn",
"sonarjs/prefer-immediate-return": "warn",
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11336-added-1732711112187.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

unit test cases for `DocsLink` component ([#11336](https://github.com/linode/manager/pull/11336))
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11337-added-1732714227095.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

Linter rules for naming convention ([#11337](https://github.com/linode/manager/pull/11337))
27 changes: 27 additions & 0 deletions packages/manager/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,33 @@ module.exports = {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/naming-convention': [
'warn',
{
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
selector: 'variable',
trailingUnderscore: 'allow',
},
{
format: null,
modifiers: ['destructured'],
selector: 'variable',
},
{
format: ['camelCase', 'PascalCase'],
selector: 'function',
},
{
format: ['camelCase'],
leadingUnderscore: 'allow',
selector: 'parameter',
},
{
format: ['PascalCase'],
selector: 'typeLike',
},
],
'@typescript-eslint/no-empty-interface': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-inferrable-types': 'off',
Expand Down
45 changes: 45 additions & 0 deletions packages/manager/src/components/DocsLink/DocsLink.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import userEvent from '@testing-library/user-event';
import React from 'react';

import { sendHelpButtonClickEvent } from 'src/utilities/analytics/customEventAnalytics';
import { renderWithTheme } from 'src/utilities/testHelpers';

import { DocsLink } from './DocsLink';

import type { DocsLinkProps } from './DocsLink';

vi.mock('src/utilities/analytics/customEventAnalytics', () => ({
sendHelpButtonClickEvent: vi.fn(),
}));

const mockLabel = 'Custom Doc Link Label';
const mockHref =
'https://techdocs.akamai.com/cloud-computing/docs/faqs-for-compute-instances';
const mockAnalyticsLabel = 'Label';

const defaultProps: DocsLinkProps = {
analyticsLabel: mockAnalyticsLabel,
href: mockHref,
label: mockLabel,
};

describe('DocsLink', () => {
it('should render the label', () => {
const { getByText } = renderWithTheme(<DocsLink {...defaultProps} />);
expect(getByText(mockLabel)).toBeVisible();
});

it('should allow user to click the label and redirect to the url', async () => {
const { getByRole } = renderWithTheme(<DocsLink {...defaultProps} />);
const link = getByRole('link', {
name: 'Custom Doc Link Label - link opens in a new tab',
});
expect(link).toBeInTheDocument();
await userEvent.click(link);
expect(sendHelpButtonClickEvent).toHaveBeenCalledTimes(1);
expect(sendHelpButtonClickEvent).toHaveBeenCalledWith(
mockHref,
mockAnalyticsLabel
);
});
});

0 comments on commit 1d582ab

Please sign in to comment.