Skip to content

Commit

Permalink
chore(lint & format): make eslint and prettier work together
Browse files Browse the repository at this point in the history
  • Loading branch information
Retro authored and Retro committed Aug 27, 2024
1 parent 0d73380 commit f8f8a75
Show file tree
Hide file tree
Showing 53 changed files with 350 additions and 291 deletions.
20 changes: 10 additions & 10 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@ module.exports = {
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:svelte/recommended",
"prettier"
"prettier",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
parserOptions: {
sourceType: "module",
ecmaVersion: 2020,
extraFileExtensions: [".svelte"]
extraFileExtensions: [".svelte"],
},
env: {
browser: true,
es2017: true,
node: true
node: true,
},
overrides: [
{
files: ["*.svelte"],
parser: "svelte-eslint-parser",
parserOptions: {
parser: "@typescript-eslint/parser"
}
}
parser: "@typescript-eslint/parser",
},
},
],
rules: {
semi: [1, "always"],
quotes: [1, "double", "avoid-escape"],
curly: [1, "multi-line"],
"space-before-function-paren": [2, "never"],
"space-before-function-paren": "off",
"@typescript-eslint/semi": [1, "always"],
"@typescript-eslint/quotes": [1, "double", "avoid-escape"],
"@typescript-eslint/space-before-function-paren": [2, "never"],
"@typescript-eslint/space-before-function-paren": "off",
"no-use-before-define": 0,
"no-unused-vars": 0,
"@typescript-eslint/no-use-before-define": 2,
Expand All @@ -47,6 +47,6 @@ module.exports = {
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-unsafe-argument": 0,
"spaced-comment": 0,
"eol-last": ["error", "always"]
}
"eol-last": ["error", "always"],
},
};
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- name: Install dependencies
run: pnpm install

- name: Check Prettier format
run: pnpm format:check

- name: Run ESLint
run: pnpm lint:noformat
# tests are not testing 😭
Expand Down
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"useTabs": true,
"singleQuote": false,
"trailingComma": "none",
"trailingComma": "es5",
"printWidth": 100,
"semi": true,
"plugins": ["prettier-plugin-svelte"],
"plugins": ["prettier-plugin-svelte", "eslint-plugin-prettier"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
10 changes: 5 additions & 5 deletions docs/blocks/BlockCreation.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ const blocks: BlockDefinition[] = [
helpUrl: "https://wiki.discodes.xyz/",
code: (args) => {
return `console.log("Hello World")`;
}
}
},
},
];
```

Expand Down Expand Up @@ -185,7 +185,7 @@ import TextInput from "$lib/utils/BlockGen/Inputs/TextInput";

const blocks: BlockDefinition[] = {
// All the properties
args: [new TextInput("TEXT", "Hello World")]
args: [new TextInput("TEXT", "Hello World")],
};
```

Expand Down Expand Up @@ -228,8 +228,8 @@ const blocks: BlockDefinition[] = [
inline: true,
colour: "#5ba58c",
tooltip: "This block prints Hello World.",
helpUrl: "https://wiki.discodes.xyz/"
}
helpUrl: "https://wiki.discodes.xyz/",
},
];
```

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"daisyui": "^4.9.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-svelte": "^2.35.1",
"postcss": "^8.4.37",
"prettier": "^3.1.1",
Expand Down
4 changes: 2 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import type { PlaywrightTestConfig } from "@playwright/test";
const config: PlaywrightTestConfig = {
webServer: {
command: "npm run build && npm run preview",
port: 4173
port: 4173,
},
testDir: "tests",
testMatch: /(.+\.)?(test|spec)\.[jt]s/
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
};

export default config;
55 changes: 55 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
autoprefixer: {},
},
};
26 changes: 13 additions & 13 deletions src/lib/blocks/Javascript/Loops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ const blocks: BlockDefinition[] = [
helpUrl: "",
code: (args) => {
return `for (let i = 0; i < ${args.VALUE === "" ? "0" : args.VALUE}; i++) {\n${args.INPUT === "" ? "" : args.INPUT}\n}`;
}
},
},
{
id: "repeat_while",
text: "Repeat {WHILE} {CONDITION}\n {INPUT}",
args: [
new Dropdown("WHILE", DropdownType.Auto, {
while: "while",
until: "until"
until: "until",
}),
new ValueInput("CONDITION", BlockType.Boolean),
new StatementInput("INPUT")
new StatementInput("INPUT"),
],
shape: BlockShape.Action,
inline: true,
Expand All @@ -39,7 +39,7 @@ const blocks: BlockDefinition[] = [
helpUrl: "",
code: (args) => {
return `while (${args.WHILE === "while" ? "" : "!"}( ${args.CONDITION === "" ? "false" : args.CONDITION} )) {\n${args.INPUT === "" ? "" : args.INPUT}\n}`;
}
},
},
{
/**
Expand All @@ -52,7 +52,7 @@ const blocks: BlockDefinition[] = [
new ValueInput("START", BlockType.Number),
new ValueInput("END", BlockType.Number),
new ValueInput("STEP", BlockType.Number),
new StatementInput("INPUT")
new StatementInput("INPUT"),
],
shape: BlockShape.Action,
inline: true,
Expand All @@ -69,15 +69,15 @@ const blocks: BlockDefinition[] = [
return `for(let vk${varName} = 0; false; vk${varName}+= 0) {}`;
}
return `for (${variable}; ${condition}; ${step}) {\n${args.INPUT}\n}`;
}
},
},
{
id: "array_iteration",
text: "For each {ITEM} in {ARRAY}\n {INPUT}",
args: [
new ValueInput("ITEM", BlockType.Any),
new ValueInput("ARRAY", BlockType.Array),
new StatementInput("INPUT")
new StatementInput("INPUT"),
],
shape: BlockShape.Action,
inline: true,
Expand All @@ -86,16 +86,16 @@ const blocks: BlockDefinition[] = [
helpUrl: "",
code: (args) => {
return `for (let ${args.ITEM} of ${args.ARRAY}) {\n${args.INPUT}\n}`;
}
},
},
{
id: "break",
text: "{ACTION} of loop",
args: [
new Dropdown("ACTION", DropdownType.Auto, {
break: "break",
continue: "continue"
})
continue: "continue",
}),
],
shape: BlockShape.Action,
inline: true,
Expand All @@ -104,12 +104,12 @@ const blocks: BlockDefinition[] = [
helpUrl: "",
code: (args) => {
return `${args.ACTION};`;
}
}
},
},
];

const category: CategoryDefinition = {
name: "Loops",
colour: rgbToHex(91, 165, 91)
colour: rgbToHex(91, 165, 91),
};
export default { blocks, category };
Loading

0 comments on commit f8f8a75

Please sign in to comment.