Fix docker install (#2925)
* Fix docker install * Move back twenty-eslint-plugin to eslint-plugin-twenty * fix: add bundled yarn * Improve makeifle structure * Update commands and doc * Add pg_graphql binaries * Fix --------- Co-authored-by: Jérémy Magrin <jeremy.magrin@gmail.com>
This commit is contained in:
@ -0,0 +1,47 @@
|
||||
import { RuleTester } from "@typescript-eslint/rule-tester";
|
||||
|
||||
import componentPropsNamingRule from "../rules/component-props-naming";
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
tsconfigRootDir: __dirname,
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
ruleTester.run("component-props-naming", componentPropsNamingRule, {
|
||||
valid: [
|
||||
{
|
||||
code: "export const MyComponent= (props: MyComponentProps) => <div>{props.message}</div>;",
|
||||
},
|
||||
{
|
||||
code: "export const MyComponent = ({ message }: MyComponentProps) => <div>{message}</div>;",
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: "export const MyComponent = (props: OwnProps) => <div>{props.message}</div>;",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidPropsTypeName",
|
||||
},
|
||||
],
|
||||
output:
|
||||
"export const MyComponent = (props: MyComponentProps) => <div>{props.message}</div>;",
|
||||
},
|
||||
{
|
||||
code: "export const MyComponent = ({ message }: OwnProps) => <div>{message}</div>;",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidPropsTypeName",
|
||||
},
|
||||
],
|
||||
output:
|
||||
"export const MyComponent = ({ message }: MyComponentProps) => <div>{message}</div>;",
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -0,0 +1,85 @@
|
||||
import { RuleTester } from "@typescript-eslint/rule-tester";
|
||||
|
||||
import effectComponentsRule from "../rules/effect-components";
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
tsconfigRootDir: __dirname,
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
ruleTester.run("effect-components", effectComponentsRule, {
|
||||
valid: [
|
||||
{
|
||||
code: `const TestComponentEffect = () => <></>;`,
|
||||
},
|
||||
{
|
||||
code: `const TestComponent = () => <div></div>;`,
|
||||
},
|
||||
{
|
||||
code: `export const useUpdateEffect = () => null;`,
|
||||
},
|
||||
{
|
||||
code: `export const useUpdateEffect = () => <></>;`,
|
||||
},
|
||||
{
|
||||
code: `const TestComponent = () => <><div></div></>;`,
|
||||
},
|
||||
{
|
||||
code: `const TestComponentEffect = () => null;`,
|
||||
},
|
||||
{
|
||||
code: `const TestComponentEffect = () => {
|
||||
useEffect(() => {}, []);
|
||||
|
||||
return null;
|
||||
}`,
|
||||
},
|
||||
{
|
||||
code: `const TestComponentEffect = () => {
|
||||
useEffect(() => {}, []);
|
||||
|
||||
return <></>;
|
||||
}`,
|
||||
},
|
||||
{
|
||||
code: `const TestComponentEffect = () => {
|
||||
useEffect(() => {}, []);
|
||||
|
||||
return <></>;
|
||||
}`,
|
||||
},
|
||||
{
|
||||
code: `const TestComponentEffect = () => {
|
||||
useEffect(() => {}, []);
|
||||
|
||||
return null;
|
||||
}`,
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: "const TestComponent = () => <></>;",
|
||||
output: "const TestComponentEffect = () => <></>;",
|
||||
errors: [
|
||||
{
|
||||
messageId: "effectSuffix",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: "const TestComponentEffect = () => <><div></div></>;",
|
||||
output: "const TestComponent = () => <><div></div></>;",
|
||||
errors: [
|
||||
{
|
||||
messageId: "noEffectSuffix",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
1
packages/eslint-plugin-twenty/src/tests/file.ts
Normal file
1
packages/eslint-plugin-twenty/src/tests/file.ts
Normal file
@ -0,0 +1 @@
|
||||
// Required by typescript-eslint https://typescript-eslint.io/packages/rule-tester#type-aware-testing
|
||||
@ -0,0 +1,185 @@
|
||||
import { RuleTester } from "@typescript-eslint/rule-tester";
|
||||
|
||||
import matchingStateVariableRule from "../rules/matching-state-variable";
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
tsconfigRootDir: __dirname,
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
ruleTester.run("matching-state-variable", matchingStateVariableRule, {
|
||||
valid: [
|
||||
{
|
||||
code: "const variable = useRecoilValue(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const variable = useRecoilScopedValue(variableScopedState);",
|
||||
},
|
||||
{
|
||||
code: "const [variable, setVariable] = useRecoilState(variableScopedState);",
|
||||
},
|
||||
{
|
||||
code: "const [variable, setVariable] = useRecoilScopedState(variableScopedState);",
|
||||
},
|
||||
{
|
||||
code: "const [variable, setVariable] = useRecoilFamilyState(variableScopedState);",
|
||||
},
|
||||
{
|
||||
code: "const [variable, setVariable] = useRecoilScopedFamilyState(variableScopedState);",
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: "const myValue = useRecoilValue(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
],
|
||||
output: "const variable = useRecoilValue(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const myValue = useRecoilScopedValue(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
],
|
||||
output: "const variable = useRecoilScopedValue(variableState);",
|
||||
},
|
||||
|
||||
{
|
||||
code: "const [myValue, setMyValue] = useRecoilState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
{
|
||||
messageId: "invalidSetterName",
|
||||
},
|
||||
],
|
||||
output: "const [variable, setVariable] = useRecoilState(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const [myValue] = useRecoilState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
],
|
||||
output: "const [variable] = useRecoilState(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const [, setMyValue] = useRecoilState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidSetterName",
|
||||
},
|
||||
],
|
||||
output: "const [, setVariable] = useRecoilState(variableState);",
|
||||
},
|
||||
|
||||
{
|
||||
code: "const [myValue, setMyValue] = useRecoilScopedState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
{
|
||||
messageId: "invalidSetterName",
|
||||
},
|
||||
],
|
||||
output:
|
||||
"const [variable, setVariable] = useRecoilScopedState(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const [myValue] = useRecoilScopedState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
],
|
||||
output: "const [variable] = useRecoilScopedState(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const [, setMyValue] = useRecoilScopedState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidSetterName",
|
||||
},
|
||||
],
|
||||
output: "const [, setVariable] = useRecoilScopedState(variableState);",
|
||||
},
|
||||
|
||||
{
|
||||
code: "const [myValue, setMyValue] = useRecoilFamilyState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
{
|
||||
messageId: "invalidSetterName",
|
||||
},
|
||||
],
|
||||
output:
|
||||
"const [variable, setVariable] = useRecoilFamilyState(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const [myValue] = useRecoilFamilyState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
],
|
||||
output: "const [variable] = useRecoilFamilyState(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const [, setMyValue] = useRecoilFamilyState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidSetterName",
|
||||
},
|
||||
],
|
||||
output: "const [, setVariable] = useRecoilFamilyState(variableState);",
|
||||
},
|
||||
|
||||
{
|
||||
code: "const [myValue, setMyValue] = useRecoilScopedFamilyState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
{
|
||||
messageId: "invalidSetterName",
|
||||
},
|
||||
],
|
||||
output:
|
||||
"const [variable, setVariable] = useRecoilScopedFamilyState(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const [myValue] = useRecoilScopedFamilyState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidVariableName",
|
||||
},
|
||||
],
|
||||
output: "const [variable] = useRecoilScopedFamilyState(variableState);",
|
||||
},
|
||||
{
|
||||
code: "const [, setMyValue] = useRecoilScopedFamilyState(variableState);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "invalidSetterName",
|
||||
},
|
||||
],
|
||||
output:
|
||||
"const [, setVariable] = useRecoilScopedFamilyState(variableState);",
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -0,0 +1,62 @@
|
||||
import { RuleTester } from "@typescript-eslint/rule-tester";
|
||||
|
||||
import noHardcodedColorsRule from "../rules/no-hardcoded-colors";
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
tsconfigRootDir: __dirname,
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
ruleTester.run("no-hardcoded-colors", noHardcodedColorsRule, {
|
||||
valid: [
|
||||
{
|
||||
code: "const color = theme.background.secondary;",
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: 'const color = "rgb(154,205,50)";',
|
||||
errors: [
|
||||
{
|
||||
messageId: "hardcodedColor",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: 'const color = { test: "rgb(154,205,50)", test2: "#ADFF2F" }',
|
||||
errors: [
|
||||
{
|
||||
messageId: "hardcodedColor",
|
||||
},
|
||||
{
|
||||
messageId: "hardcodedColor",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: "const color = { test: `rgb(${r},${g},${b})`, test2: `#ADFF${test}` }",
|
||||
errors: [
|
||||
{
|
||||
messageId: "hardcodedColor",
|
||||
},
|
||||
{
|
||||
messageId: "hardcodedColor",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: 'const color = "#ADFF2F";',
|
||||
errors: [
|
||||
{
|
||||
messageId: "hardcodedColor",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -0,0 +1,51 @@
|
||||
import { RuleTester } from "@typescript-eslint/rule-tester";
|
||||
|
||||
import noStateUseRefRule from "../rules/no-state-useref";
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
tsconfigRootDir: __dirname,
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
ruleTester.run("no-state-useref", noStateUseRefRule, {
|
||||
valid: [
|
||||
{
|
||||
code: "const scrollableRef = useRef<HTMLDivElement>(null);",
|
||||
},
|
||||
{
|
||||
code: "const ref = useRef<HTMLInputElement>(null);",
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: "const ref = useRef(null);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "noStateUseRef",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: "const ref = useRef<Boolean>(null);",
|
||||
errors: [
|
||||
{
|
||||
messageId: "noStateUseRef",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: "const ref = useRef<string>('');",
|
||||
errors: [
|
||||
{
|
||||
messageId: "noStateUseRef",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
1
packages/eslint-plugin-twenty/src/tests/react.tsx
Normal file
1
packages/eslint-plugin-twenty/src/tests/react.tsx
Normal file
@ -0,0 +1 @@
|
||||
// Required by typescript-eslint https://typescript-eslint.io/packages/rule-tester#type-aware-testing
|
||||
@ -0,0 +1,56 @@
|
||||
import { RuleTester } from "@typescript-eslint/rule-tester";
|
||||
|
||||
import sortCssPropertiesAlphabeticallyRule from "../rules/sort-css-properties-alphabetically";
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
tsconfigRootDir: __dirname,
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
ruleTester.run(
|
||||
"sort-css-properties-alphabetically",
|
||||
sortCssPropertiesAlphabeticallyRule,
|
||||
{
|
||||
valid: [
|
||||
{
|
||||
code: "const style = css`color: red;`;",
|
||||
},
|
||||
{
|
||||
code: "const style = css`background-color: $bgColor;color: red;`;",
|
||||
},
|
||||
{
|
||||
code: "const StyledComponent = styled.div`color: red;`;",
|
||||
},
|
||||
{
|
||||
code: "const StyledComponent = styled.div`background-color: $bgColor;color: red;`;",
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: "const style = css`color: #FF0000;background-color: $bgColor`;",
|
||||
output: "const style = css`background-color: $bgColorcolor: #FF0000;`;",
|
||||
errors: [
|
||||
{
|
||||
messageId: "sortCssPropertiesAlphabetically",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: "const StyledComponent = styled.div`color: #FF0000;background-color: $bgColor`;",
|
||||
output:
|
||||
"const StyledComponent = styled.div`background-color: $bgColorcolor: #FF0000;`;",
|
||||
errors: [
|
||||
{
|
||||
messageId: "sortCssPropertiesAlphabetically",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
@ -0,0 +1,47 @@
|
||||
import { RuleTester } from "@typescript-eslint/rule-tester";
|
||||
|
||||
import styledComponentsPrefixedWithStyledRule from "../rules/styled-components-prefixed-with-styled";
|
||||
|
||||
const ruleTester = new RuleTester({
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
tsconfigRootDir: __dirname,
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
ruleTester.run(
|
||||
"styled-components-prefixed-with-styled",
|
||||
styledComponentsPrefixedWithStyledRule,
|
||||
{
|
||||
valid: [
|
||||
{
|
||||
code: "const StyledButton = styled.button``;",
|
||||
},
|
||||
{
|
||||
code: "const StyledComponent = styled.div``;",
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: "const Button = styled.button``;",
|
||||
errors: [
|
||||
{
|
||||
messageId: "noStyledPrefix",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
code: "const Component = styled.div``;",
|
||||
errors: [
|
||||
{
|
||||
messageId: "noStyledPrefix",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
6
packages/eslint-plugin-twenty/src/tests/tsconfig.json
Normal file
6
packages/eslint-plugin-twenty/src/tests/tsconfig.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true
|
||||
},
|
||||
"include": ["./file.ts", "./react.tsx"]
|
||||
}
|
||||
Reference in New Issue
Block a user