Skip to content

Commit

Permalink
ci: add eslint to json server
Browse files Browse the repository at this point in the history
  • Loading branch information
nattb8 committed May 28, 2024
1 parent 45b2d11 commit 35996e9
Show file tree
Hide file tree
Showing 6 changed files with 2,081 additions and 22 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,13 @@ jobs:
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_TYPESCRIPT_ES: false
VALIDATE_TYPESCRIPT_STANDARD: false

##################################
# Run eslint against json-server #
##################################
- name: Install packages for json-server
working-directory: ./json-server
run: yarn install
- name: Run eslint
working-directory: ./json-server
run: yarn lint
31 changes: 31 additions & 0 deletions json-server/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const importPlugin = require('eslint-plugin-import');
const tseslint = require('typescript-eslint');
const { FlatCompat } = require('@eslint/eslintrc');

const compat = new FlatCompat({
baseDirectory: __dirname,
});

module.exports = tseslint.config(
{
ignores: [
'node_modules/**',
'dest/**',
'eslint.config.js',
],
},
...compat.extends('eslint-config-airbnb-typescript/base'),
{
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true,
},
},
plugins: {
import: importPlugin,
},
rules: {
},
},
);
14 changes: 12 additions & 2 deletions json-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@
"scripts": {
"start": "node ./dest/index.js",
"build": "yarn clean && tsc --build",
"clean": "rm -rf ./dest"
"clean": "rm -rf ./dest",
"lint": "eslint ."
},
"devDependencies": {
"@types/cors": "^2.8.13",
"@types/express": "^4.17.17",
"typescript": "^5.1.6"
"@typescript-eslint/eslint-plugin": "^7.11.0",
"eslint": "^8.56.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"typescript": "^5.4.5",
"typescript-eslint": "^7.11.0"
},
"dependencies": {
"cors": "^2.8.5",
Expand Down
22 changes: 11 additions & 11 deletions json-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import express, {
Express,
Express,
Router,
Request,
Response
Response,
} from 'express';
import cors from 'cors';
import http from 'http';

const foxImageUrl = 'https://rose-ministerial-termite-701.mypinata.cloud/ipfs/Qmd3oT99HypRHaPfiY6JWokxADR5TzR1stgonFy1rMZAUy'
const foxImageUrl = 'https://rose-ministerial-termite-701.mypinata.cloud/ipfs/Qmd3oT99HypRHaPfiY6JWokxADR5TzR1stgonFy1rMZAUy';
const skinImageUrl = 'https://rose-ministerial-termite-701.mypinata.cloud/ipfs/QmNZeG8wkW3mFw4PrqEj34NPA88impcvemYjhAkJAM4YcK';

const app: Express = express();
Expand All @@ -21,13 +21,13 @@ router.get(
const json = {
id: parseInt(req.params.id),
name: `Fox #${req.params.id}`,
image: foxImageUrl
image: foxImageUrl,
};

res.writeHead(200);

res.end(JSON.stringify(json));
}
},
);

router.get(
Expand All @@ -36,18 +36,18 @@ router.get(
const json = {
id: parseInt(req.params.id),
name: `Skin #${req.params.id}`,
image: skinImageUrl
image: skinImageUrl,
};

res.writeHead(200);

res.end(JSON.stringify(json));
}
},
);

app.use('/', router);

http.createServer(app).listen(
3000,
() => console.log(`Listening on port 3000`)
3000,
() => console.log('Listening on port 3000'),
);
5 changes: 4 additions & 1 deletion json-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"./src/*"
]
}
}
},
"include": [
"src",
],
}
Loading

0 comments on commit 35996e9

Please sign in to comment.