Skip to content

The open alternative to Salesforce, designed for AI.

Fix tests

Charles Bochet2adabb3ba2e0
diff --git a/packages/eslint-plugin-twenty-ts/src/rules/no-hardcoded-colors.ts b/packages/eslint-plugin-twenty-ts/src/rules/no-hardcoded-colors.ts
index 1a1366d0018..9c542d9e50c 100644
--- a/packages/eslint-plugin-twenty-ts/src/rules/no-hardcoded-colors.ts
+++ b/packages/eslint-plugin-twenty-ts/src/rules/no-hardcoded-colors.ts
@@ -17,7 +17,7 @@ const noHardcodedColorsRule = createRule({
if (colorRegex.test(quasi.value.raw)) {
context.report({
node,
- messageId: "avoidHardcodedColors",
+ messageId: "hardcodedColor",
data: {
color: quasi.value.raw,
},
@@ -27,21 +27,21 @@ const noHardcodedColorsRule = createRule({
},
};
},
- name: "avoid-hardcoded-colors",
+ name: "no-hardcoded-colors",
meta: {
- type: "suggestion",
docs: {
- description: "Avoid hardcoded RGBA or Hex colors, use colors from the theme file.",
- recommended: "recommended",
+ description:
+ "Do not use hardcoded RGBA or Hex colors. Please use a color from the theme file.",
},
- schema: [],
- fixable: "code",
messages: {
- avoidHardcodedColors:
- "Do not use hardcoded RGBA or Hex colors. Please use a color from the theme file.",
+ hardcodedColor:
+ "Hardcoded color {{ color }} found. Please use a color from the theme file.",
},
+ type: "suggestion",
+ schema: [],
+ fixable: "code",
},
- defaultOptions: []
+ defaultOptions: [],
});
module.exports = noHardcodedColorsRule;
diff --git a/packages/eslint-plugin-twenty-ts/src/tests/no-hardcoded-colors.spec.ts b/packages/eslint-plugin-twenty-ts/src/tests/no-hardcoded-colors.spec.ts
index 10013637ef5..51e17ce63f7 100644
--- a/packages/eslint-plugin-twenty-ts/src/tests/no-hardcoded-colors.spec.ts
+++ b/packages/eslint-plugin-twenty-ts/src/tests/no-hardcoded-colors.spec.ts
@@ -1,7 +1,6 @@
import { RuleTester } from "@typescript-eslint/rule-tester";
import noHardcodedColorsRule from "../rules/no-hardcoded-colors";
-
const ruleTester = new RuleTester({
parser: "@typescript-eslint/parser",
parserOptions: {
@@ -16,41 +15,28 @@ const ruleTester = new RuleTester({
ruleTester.run("no-hardcoded-colors", noHardcodedColorsRule, {
valid: [
{
- code: 'const color = theme.primaryColor;',
- filename: 'example.ts',
+ code: "const color = theme.background.secondary;",
},
{
- code: 'const color = "#FFFFFF";',
- filename: 'example.ts',
+ code: 'const color = "#000000";',
},
],
invalid: [
{
- code: 'const color = "#FF0000";',
- filename: 'example.ts',
- errors: [
- {
- messageId: 'avoidHardcodedColors',
- },
- ],
- },
- {
- code: 'const color = "rgba(255, 0, 0, 0.5)";',
- filename: 'example.ts',
+ code: 'const color = "rgb(154,205,50)";',
errors: [
{
- messageId: 'avoidHardcodedColors',
+ messageId: "hardcodedColor",
},
],
},
{
- code: 'const color = "#123456";',
- filename: 'themes.ts',
+ code: 'const color = "#ADFF2F";',
errors: [
{
- messageId: 'avoidHardcodedColors',
+ messageId: "hardcodedColor",
},
],
},
],
-});
+});
\ No newline at end of file
diff --git a/packages/eslint-plugin-twenty-ts/src/tests/sort-css-properties-alphabetically.spec.ts b/packages/eslint-plugin-twenty-ts/src/tests/sort-css-properties-alphabetically.spec.ts
index 3d5f43534a9..df43067e2af 100644
--- a/packages/eslint-plugin-twenty-ts/src/tests/sort-css-properties-alphabetically.spec.ts
+++ b/packages/eslint-plugin-twenty-ts/src/tests/sort-css-properties-alphabetically.spec.ts
@@ -16,18 +16,17 @@ ruleTester.run("sort-css-properties-alphabetically", sortCssPropertiesAlphabetic
valid: [
{
code: 'const style = css`color: red;`;',
- filename: 'example.ts',
+ filename: 'react.tsx',
},
{
code: 'const style = styled.div`background-color: $bgColor;`;',
- filename: 'example.ts',
+ filename: 'react.tsx',
},
- // Add more valid cases as needed
],
invalid: [
{
code: 'const style = css`color: #FF0000;`;',
- filename: 'example.ts',
+ filename: 'react.tsx',
errors: [
{
messageId: "sort-css-properties-alphabetically",
@@ -42,7 +41,7 @@ ruleTester.run("sort-css-properties-alphabetically", sortCssPropertiesAlphabetic
},
{
code: 'const style = styled.div`background-color: $bgColor; color: #FFFFFF;`;',
- filename: 'example.ts',
+ filename: 'react.tsx',
errors: [
{
messageId: "sort-css-properties-alphabetically",
@@ -55,6 +54,5 @@ ruleTester.run("sort-css-properties-alphabetically", sortCssPropertiesAlphabetic
},
],
},
- // Add more invalid cases as needed
],
});
diff --git a/packages/eslint-plugin-twenty-ts/src/tests/styled-components-prefixed-with-styled.spec.ts b/packages/eslint-plugin-twenty-ts/src/tests/styled-components-prefixed-with-styled.spec.ts
index 3f1fedd7704..19da8e8da35 100644
--- a/packages/eslint-plugin-twenty-ts/src/tests/styled-components-prefixed-with-styled.spec.ts
+++ b/packages/eslint-plugin-twenty-ts/src/tests/styled-components-prefixed-with-styled.spec.ts
@@ -16,18 +16,17 @@ ruleTester.run("styled-components-prefixed-with-styled", styledComponentsPrefixe
valid: [
{
code: 'const StyledButton = styled.button``;',
- filename: 'example.ts',
+ filename: 'react.tsx',
},
{
code: 'const StyledComponent = styled.div``;',
- filename: 'example.ts',
+ filename: 'react.tsx',
},
-
],
invalid: [
{
code: 'const Button = styled.button``;',
- filename: 'example.ts',
+ filename: 'react.tsx',
errors: [
{
messageId: 'noStyledPrefix',
@@ -36,40 +35,12 @@ ruleTester.run("styled-components-prefixed-with-styled", styledComponentsPrefixe
},
{
code: 'const Component = styled.div``;',
- filename: 'example.ts',
- errors: [
- {
- messageId: 'noStyledPrefix',
- },
- ],
- },
- {
- code: 'const styled = {}; const Button = styled.button``;',
- filename: 'example.ts',
- errors: [
- {
- messageId: 'noStyledPrefix',
- },
- ],
- },
- {
- code: 'const styled = {}; const Component = styled.div``;',
- filename: 'example.ts',
- errors: [
- {
- messageId: 'noStyledPrefix',
- },
- ],
- },
- {
- code: 'const StyledButton = styled.button``;',
- filename: 'themes.ts',
+ filename: 'react.tsx',
errors: [
{
messageId: 'noStyledPrefix',
},
],
},
-
],
});