Skip to content

Commit

Permalink
Infra update 2024 (#35)
Browse files Browse the repository at this point in the history
* Fixed mutation issues

* Updated infrastructure to latest versions

* Added prettier check to husky precommit check

* Updated spec tests

* Updated precommit and changed dependencies

* Added storybook for shared blocks

* Updated github build pipeline

* Added separate stages to the workflow file

* Updated package-lock and removed hack

* Updated package json dependencies

* Fixed aliases for storybook, added storybook to components

* Moved favicons to tailwind.css
  • Loading branch information
PsychoSanchez authored Nov 2, 2024
1 parent d8a5b8f commit 5f3ded3
Show file tree
Hide file tree
Showing 86 changed files with 11,187 additions and 11,361 deletions.
35 changes: 0 additions & 35 deletions .eslintrc.js

This file was deleted.

37 changes: 35 additions & 2 deletions .github/workflows/webpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,54 @@ on:
branches: [ "main" ]

jobs:
lint:
runs-on: ubuntu-latest
name: Lint code
steps:
- uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 23

- name: Lint
run: |
npm install
npm run ci:lint
test:
runs-on: ubuntu-latest
name: Run tests
steps:
- uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 23

- name: Test
run: |
npm install
npm run ci:test
build:
runs-on: ubuntu-latest
name: Build production
needs: [lint, test]
steps:
- uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 23

- name: Build
run: |
npm install
npx webpack --mode=production
npm run ci:build
- name: Archive production artifacts
uses: actions/upload-artifact@v3
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,5 @@ dist
# TernJS port file
.tern-port

.vscode
.vscode
*storybook.log
16 changes: 16 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0

# Prettify all selected files
echo "$FILES" | npm run prettier:write

# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add

if npm run prettier:check; then
echo "Prettier passed"
else
echo "Prettier failed"
exit 1
fi

npm run lint
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.13.2
v23.1.0
44 changes: 44 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { StorybookConfig } from '@storybook/react-webpack5';

const config: StorybookConfig = {
stories: ['../src/**/*.stories.@(ts|tsx)'],
addons: [
'@storybook/addon-webpack5-compiler-swc',
'@storybook/addon-essentials',
'@storybook/addon-styling-webpack',
],
framework: {
name: '@storybook/react-webpack5',
options: {},
},
webpackFinal: async (config) => {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const path = require('path');
// eslint-disable-next-line @typescript-eslint/no-require-imports
const tsConfig = require('../tsconfig.json');
const __dirname = path.resolve();

function createWebpackAliasFromTsConfigPaths() {
return Object.fromEntries(
Object.entries<[string, string[]]>(
tsConfig.compilerOptions.paths || {},
).map(([key, [value]]) => [
key.replace('/*', ''),
path.resolve(__dirname, value.replace('/*', '')),
]),
);
}

return {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve?.alias,
...createWebpackAliasFromTsConfigPaths(),
},
},
};
},
};
export default config;
16 changes: 16 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Preview } from '@storybook/react';

import '!style-loader!css-loader!postcss-loader!../src/tailwind.css';

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
72 changes: 72 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import react from 'eslint-plugin-react';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ['dist/*', 'tools/*', 'node_modules/*', 'static/*'],
},
...fixupConfigRules(
compat.extends(
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:@typescript-eslint/recommended',
),
),
{
settings: {
react: {
pragma: 'React',
version: 'detect',
},
},

plugins: {
react: fixupPluginRules(react),
'@typescript-eslint': fixupPluginRules(typescriptEslint),
},

languageOptions: {
globals: {
...globals.browser,
},

parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',
},

rules: {
'react/prop-types': 'off',
'react/display-name': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-explicit-any': 'off',

'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],

'react-hooks/exhaustive-deps': 'error',
},
},
];
5 changes: 0 additions & 5 deletions jest.config.js

This file was deleted.

13 changes: 13 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { pathsToModuleNameMapper } from 'ts-jest';
import type { JestConfigWithTsJest } from 'ts-jest';

// eslint-disable-next-line @typescript-eslint/no-require-imports
const { compilerOptions } = require('./tsconfig.json');

export default {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>'],
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
} satisfies JestConfigWithTsJest;
Loading

0 comments on commit 5f3ded3

Please sign in to comment.