Skip to content

Commit

Permalink
Add ESLint rule to check for relative imports
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed Jan 10, 2024
1 parent cfe2983 commit 2b2eed5
Show file tree
Hide file tree
Showing 4 changed files with 475 additions and 8 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@ jobs:
bundler-cache: true
- name: Lint Ruby files
run: bundle exec standardrb
ESLint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Restore node_modules cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package.json') }}
restore-keys: |
${{ runner.os }}-node-modules
- name: Install dependencies
run: yarn install
- name: Lint code
run: yarn eslint
Prettier:
runs-on: ubuntu-latest
steps:
Expand Down
17 changes: 17 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default [
{
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: ["./", "../"],
message: "Relative imports are not allowed."
}
]
}
]
}
}
]
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"scripts": {
"test": "jest",
"lint": "prettier --check 'app/javascript/**/*.js'",
"eslint": "eslint app/javascript/**/*.js",
"build": "rollup -c"
},
"keywords": [],
"author": "Thomas von Deyen",
"license": "BSD-3-Clause",
"type": "module",
"dependencies": {
"@rails/ujs": "^7.1.2",
"@shoelace-style/shoelace": "^2.12.0",
Expand All @@ -25,6 +27,7 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"babel-jest": "^29.6.4",
"eslint": "^8.56.0",
"jest": "^29.6.4",
"jest-environment-jsdom": "^29.6.4",
"jquery": "^3.7.1",
Expand Down
Loading

0 comments on commit 2b2eed5

Please sign in to comment.