Skip to content

Commit 8125879

Browse files
committed
chore: improve sb, tsc configs
Summary: This commit is a bit of a shotgun fix for various project settings. Realistically, they could've been separate commits, but this is convenience for just getting things into a green state to unblock further work. Details: - Use our version of TS in vscode plugins - organize vscode/settings.json - fix tsconfig.test and tsconfig.prod (removes errors in test files) - only use prod tsconfig in webpack - point .eslintrc to both test and prod configs - cleanup storybook
1 parent 46e3888 commit 8125879

File tree

11 files changed

+76
-40
lines changed

11 files changed

+76
-40
lines changed

.vscode/settings.json

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,4 @@
11
{
2-
"files.exclude": {
3-
"**/node_modules": true
4-
},
5-
"go.lintTool": "golangci-lint",
6-
"go.lintFlags": ["--fast"],
7-
"go.lintOnSave": "package",
8-
"go.coverOnSave": true,
9-
// The codersdk is used by coderd another other packages extensively.
10-
// To reduce redundancy in tests, it's covered by other packages.
11-
"go.testFlags": ["-coverpkg=./.,github.com/coder/coder/codersdk"],
12-
"go.coverageDecorator": {
13-
"type": "gutter",
14-
"coveredHighlightColor": "rgba(64,128,128,0.5)",
15-
"uncoveredHighlightColor": "rgba(128,64,64,0.25)",
16-
"coveredBorderColor": "rgba(64,128,128,0.5)",
17-
"uncoveredBorderColor": "rgba(128,64,64,0.25)",
18-
"coveredGutterStyle": "blockgreen",
19-
"uncoveredGutterStyle": "blockred"
20-
},
21-
"emeraldwalk.runonsave": {
22-
"commands": [
23-
{
24-
"match": "database/query.sql",
25-
"cmd": "make gen"
26-
}
27-
]
28-
},
292
"cSpell.words": [
303
"coderd",
314
"coderdtest",
@@ -76,5 +49,35 @@
7649
"xerrors",
7750
"yamux"
7851
],
79-
"eslint.workingDirectories": ["./site"]
52+
"emeraldwalk.runonsave": {
53+
"commands": [
54+
{
55+
"match": "database/query.sql",
56+
"cmd": "make gen"
57+
}
58+
]
59+
},
60+
"eslint.workingDirectories": ["./site"],
61+
"files.exclude": {
62+
"**/node_modules": true
63+
},
64+
"go.lintTool": "golangci-lint",
65+
"go.lintFlags": ["--fast"],
66+
"go.lintOnSave": "package",
67+
"go.coverOnSave": true,
68+
// The codersdk is used by coderd another other packages extensively.
69+
// To reduce redundancy in tests, it's covered by other packages.
70+
"go.testFlags": ["-coverpkg=./.,github.com/coder/coder/codersdk"],
71+
"go.coverageDecorator": {
72+
"type": "gutter",
73+
"coveredHighlightColor": "rgba(64,128,128,0.5)",
74+
"uncoveredHighlightColor": "rgba(128,64,64,0.25)",
75+
"coveredBorderColor": "rgba(64,128,128,0.5)",
76+
"uncoveredBorderColor": "rgba(128,64,64,0.25)",
77+
"coveredGutterStyle": "blockgreen",
78+
"uncoveredGutterStyle": "blockred"
79+
},
80+
// We often use a version of TypeScript that's ahead of the version shipped
81+
// with VS Code.
82+
"typescript.tsdk": "./site/node_modules/typescript/lib"
8083
}

site/.eslintrc.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ extends:
1717
parser: "@typescript-eslint/parser"
1818
parserOptions:
1919
ecmaVersion: 2018
20-
project: "./tsconfig.test.json"
20+
project:
21+
- ./tsconfig.prod.json
22+
- ./tsconfig.test.json
2123
sourceType: module
2224
ecmaFeatures:
2325
jsx: true

site/.storybook/main.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1+
/**
2+
* @fileoverview This file is configures Storybook
3+
*
4+
* @see <https://storybook.js.org/docs/react/configure/overview>
5+
*/
16
const path = require("path")
27

38
module.exports = {
4-
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
9+
// Automatically loads all stories in source ending in 'stories.tsx'
10+
//
11+
// SEE: https://storybook.js.org/docs/react/configure/overview#configure-story-loading
12+
stories: ["../src/**/*.stories.tsx"],
13+
14+
// addons are official and community plugins to extend Storybook.
15+
//
16+
// SEE: https://storybook.js.org/addons
517
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
18+
19+
// Storybook uses babel under the hood, while we currently use ts-loader.
20+
// Sometimes, you may encounter an error in a Storybook that contains syntax
21+
// that requires a babel plugin.
22+
//
23+
// SEE: https://storybook.js.org/docs/react/configure/babel
624
babel: async (options) => ({
725
...options,
826
plugins: ["@babel/plugin-proposal-class-properties"],
9-
// any extra options you want to set
1027
}),
28+
29+
// Storybook internally uses its own Webpack configuration instead of ours.
30+
//
31+
// SEE: https://storybook.js.org/docs/react/configure/webpack
1132
webpackFinal: async (config) => {
1233
config.resolve.modules = [path.resolve(__dirname, ".."), "node_modules"]
13-
1434
return config
1535
},
1636
}

site/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
{
44
globals: {
55
"ts-jest": {
6-
tsconfig: "tsconfig.test.json",
6+
tsconfig: "./tsconfig.test.json",
77
},
88
},
99
coverageReporters: ["text", "lcov"],

site/src/components/CodeBlock/index.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Started container user
99
Using user 'coder' with shell '/bin/bash'`.split("\n")
1010

1111
export default {
12-
title: "CodeBlock",
12+
title: "CodeBlock/CodeBlock",
1313
component: CodeBlock,
1414
argTypes: {
1515
lines: { control: "text", defaultValue: sampleLines },

site/src/components/CodeExample/CodeExample.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CodeExample, CodeExampleProps } from "./CodeExample"
55
const sampleCode = `echo "Hello, world"`
66

77
export default {
8-
title: "CodeExample",
8+
title: "CodeBlock/CodeExample",
99
component: CodeExample,
1010
argTypes: {
1111
code: { control: "string", defaultValue: sampleCode },

site/src/components/Workspace/Workspace.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Workspace, WorkspaceProps } from "./Workspace"
44
import { MockOrganization, MockProject, MockWorkspace } from "../../test_helpers"
55

66
export default {
7-
title: "Workspace",
7+
title: "Workspaces/Workspace",
88
component: Workspace,
99
argTypes: {},
1010
}

site/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
"target": "es5"
1717
},
1818
"include": ["**/*.ts", "**/*.tsx"],
19-
"exclude": ["node_modules", "_jest", "**/*.test.tsx?"]
19+
"exclude": ["node_modules", "_jest"]
2020
}

site/tsconfig.prod.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": ["node_modules", "_jest", "**/*.stories.tsx", "**/*.test.tsx"]
4+
}

site/tsconfig.test.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"extends": "./tsconfig.json",
3-
"include": ["**/*.test.tsx?"],
4-
"exclude": ["node_modules", "_jest"]
3+
"exclude": ["node_modules", "_jest"],
4+
"include": ["**/*.stories.tsx", "**/*.test.tsx"]
55
}

site/webpack.common.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ export const commonWebpackConfig: Configuration = {
3030
rules: [
3131
{
3232
test: /\.tsx?$/,
33-
use: ["ts-loader"],
33+
use: [
34+
{
35+
loader: "ts-loader",
36+
options: {
37+
configFile: "tsconfig.prod.json",
38+
},
39+
},
40+
],
3441
exclude: [/node_modules/],
3542
},
3643
],

0 commit comments

Comments
 (0)