-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: standardise eslint and prettier configs
- Loading branch information
Showing
33 changed files
with
839 additions
and
776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,6 @@ jobs: | |
|
||
- name: Lint 🛀 | ||
run: pnpm lint | ||
|
||
- name: Check for formatting 🧹 | ||
run: pnpm format:check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,37 @@ | ||
import { defineConfig } from "vitepress"; | ||
import { scanDir } from "./utils"; | ||
import { defineConfig } from 'vitepress' | ||
import { scanDir } from './utils' | ||
|
||
export default defineConfig({ | ||
lang: "en-US", | ||
title: "Starter Kitty", | ||
description: "Common app components that are safe-by-default.", | ||
lang: 'en-US', | ||
title: 'Starter Kitty', | ||
description: 'Common app components that are safe-by-default.', | ||
markdown: { attrs: { disable: true } }, | ||
themeConfig: { | ||
search: { | ||
provider: "local", | ||
provider: 'local', | ||
}, | ||
|
||
// https://vitepress.dev/reference/default-theme-config | ||
nav: [ | ||
{ text: "Home", link: "/" }, | ||
{ text: "Examples", link: "/examples" }, | ||
{ text: "API", link: "/api" }, | ||
{ text: 'Home', link: '/' }, | ||
{ text: 'Examples', link: '/examples' }, | ||
{ text: 'API', link: '/api' }, | ||
], | ||
|
||
socialLinks: [ | ||
{ icon: "github", link: "https://github.com/opengovsg/starter-kitty" }, | ||
], | ||
socialLinks: [{ icon: 'github', link: 'https://github.com/opengovsg/starter-kitty' }], | ||
|
||
docFooter: { | ||
prev: false, | ||
next: false, | ||
}, | ||
|
||
sidebar: { | ||
"/examples/": scanDir("examples"), | ||
"/api/": scanDir("api"), | ||
'/examples/': scanDir('examples'), | ||
'/api/': scanDir('api'), | ||
}, | ||
}, | ||
ignoreDeadLinks: [ | ||
// ignore all localhost links | ||
/^https?:\/\/localhost/, | ||
], | ||
}); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,42 @@ | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
|
||
export const scanDir = (dir: string) => { | ||
let res = fs | ||
.readdirSync(path.resolve(__dirname, `../${dir}`)) | ||
.filter((item) => !item.startsWith(".")) as string[]; | ||
let res = fs.readdirSync(path.resolve(__dirname, `../${dir}`)).filter(item => !item.startsWith('.')) as string[] | ||
if (res) { | ||
const arr = []; | ||
const arr = [] | ||
for (let item of res) { | ||
const parts = item.split("."); | ||
const parts = item.split('.') | ||
|
||
let currItem = arr; | ||
let currentPath = ""; | ||
let currItem = arr | ||
let currentPath = '' | ||
while (parts.length > 2) { | ||
const part = parts.shift(); | ||
currentPath += (currentPath === "" ? "" : ".") + part; | ||
const found = currItem.find((item) => item.text === part); | ||
const part = parts.shift() | ||
currentPath += (currentPath === '' ? '' : '.') + part | ||
const found = currItem.find(item => item.text === part) | ||
if (found) { | ||
currItem = found.items; | ||
currItem = found.items | ||
} else { | ||
const newItem = { | ||
text: part, | ||
items: [], | ||
link: path.join(dir, currentPath), | ||
}; | ||
currItem.push(newItem); | ||
currItem = newItem.items; | ||
} | ||
currItem.push(newItem) | ||
currItem = newItem.items | ||
} | ||
} | ||
const found = currItem.find((item) => item.text === parts[0]); | ||
const found = currItem.find(item => item.text === parts[0]) | ||
if (!found) | ||
currItem.push({ | ||
text: parts[0], | ||
items: [], | ||
link: path.join(dir, item), | ||
}); | ||
}) | ||
} | ||
return arr; | ||
return arr | ||
} else { | ||
console.warn("No files found in the directory"); | ||
return []; | ||
console.warn('No files found in the directory') | ||
return [] | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const { resolve } = require("node:path"); | ||
|
||
const project = resolve(process.cwd(), "tsconfig.json"); | ||
|
||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
extends: ["opengovsg"], | ||
ignorePatterns: ["dist/**/*", "vitest.config.ts", "vitest.setup.ts"], | ||
plugins: ["import", "eslint-plugin-tsdoc"], | ||
rules: { | ||
"import/no-unresolved": "error", | ||
"tsdoc/syntax": "error", | ||
}, | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: "**/tsconfig.json", | ||
}, | ||
settings: { | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [".ts", ".tsx"], | ||
}, | ||
"import/resolver": { | ||
typescript: { | ||
alwaysTryTypes: true, | ||
project: project, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "@opengovsg/eslint-config-starter-kitty", | ||
"private": true, | ||
"files": [ | ||
"index.js" | ||
], | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"eslint": "^8.56.0", | ||
"eslint-config-opengovsg": "^3.0.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"eslint-import-resolver-typescript": "^3.6.1", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-simple-import-sort": "^10.0.0", | ||
"eslint-plugin-tsdoc": "^0.3.0", | ||
"prettier": "^2.8.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
printWidth: 120, | ||
semi: false, | ||
singleQuote: true, | ||
trailingComma: "all", | ||
arrowParens: "avoid", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "@opengovsg/prettier-config-starter-kitty", | ||
"private": true, | ||
"files": [ | ||
"index.js" | ||
], | ||
"devDependencies": { | ||
"eslint": "^8", | ||
"prettier": "^2.8.4", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,8 @@ | ||
{ | ||
"extends": ["opengovsg"], | ||
"ignorePatterns": ["dist/**/*", "vitest.config.ts", "vitest.setup.ts"], | ||
"plugins": ["import", "eslint-plugin-tsdoc"], | ||
"rules": { | ||
"import/no-unresolved": "error", | ||
"tsdoc/syntax": "error" | ||
}, | ||
"root": true, | ||
"extends": ["@opengovsg/eslint-config-starter-kitty/index.js"], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "**/tsconfig.json" | ||
"project": true, | ||
}, | ||
"settings": { | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [".ts", ".tsx"] | ||
}, | ||
"import/resolver": { | ||
"typescript": { | ||
"alwaysTryTypes": true, | ||
"project": "**/tsconfig.json" | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.