Skip to content

Commit

Permalink
🚨 add basic eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
VNDRN authored and robrechtme committed May 24, 2024
1 parent c09d9b5 commit f86c34b
Show file tree
Hide file tree
Showing 8 changed files with 833 additions and 21 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
name: GitHub Actions
run-name: Running necessary checks 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
Code-Checks:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
- name: 🚚 Installing dependencies
run: yarn
- name: 🏷️ running typecheck
run: yarn build
- name: 🧪 Running tests
run: yarn test
- name: 🚨 Linting code
run: yarn lint
- name: 🚨 prettier check code
run: yarn format:check
11 changes: 11 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ignore everything except the code in src/.
# Based on https://stackoverflow.com/a/70715829/458193
*
!src/**/*.js
!src/**/*.jsx
!src/**/*.ts
!src/**/*.tsx
!src/**/*.json
!*/

# More specific ignores go below.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"editor.formatOnSave": true
}
}
21 changes: 21 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import prettierConfig from "eslint-config-prettier";

const ignoreConfig = {
ignores: ["node_modules/", "dist/", ".locorc.js"],
};

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
ignoreConfig,
prettierConfig,
{
rules: {
"@typescript-eslint/no-explicit-any": "warn",
},
},
);
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "CLI tool for syncing assets from and to Loco",
"license": "MIT",
"repository": "robrechtme/loco-cli",
"type": "module",
"author": {
"name": "Robrecht Meersman",
"email": "hello@robrecht.me",
Expand All @@ -20,6 +21,7 @@
"build": "tsc",
"format:check": "prettier --check .",
"format": "prettier --write .",
"lint": "eslint .",
"loco-cli": "yarn build && node ./dist/cli.js",
"test": "vitest run"
},
Expand All @@ -43,11 +45,16 @@
"isomorphic-unfetch": "^3.1.0"
},
"devDependencies": {
"@eslint/js": "9.2.0",
"@types/cli-progress": "3.11.0",
"@types/inquirer": "8.2.1",
"@types/node": "14.x",
"typescript": "4.9.4",
"eslint": "9.2.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"prettier": "3.2.5",
"typescript": "5.4.5",
"typescript-eslint": "7.8.0",
"vitest": "0.26.1"
}
}
2 changes: 1 addition & 1 deletion src/lib/readFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const readFilesInDir = async (path: string, separator?: string) => {
if (file.endsWith('.json')) {
const json = await readJSON(join(path, file));
Object.keys(json).forEach(key => {
// @ts-expect-error
// @ts-expect-error Element implicitly has an any type because expression of type string can't be used to index type {}.
res[`${file.replace('.json', '')}${separator}${key}`] = json[key];
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/namespaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const splitIntoNamespaces = (
acc[namespace] = {};
}
// Add the current entry to the result
// @ts-expect-error
// @ts-expect-error Element implicitly has an any type because expression of type string can't be used to index type {}.
acc[namespace][assetKey] = value;
return acc;
}, {});
Loading

0 comments on commit f86c34b

Please sign in to comment.