Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

chore: fix asset bundling #31

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .babelrc

This file was deleted.

52 changes: 52 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const isDevelopment = process.env.NODE_ENV !== 'production';

const envPreset = isDevelopment
? ['@babel/preset-env', { loose: true }]
: [
'@babel/preset-env',
{
modules: false,
// Allow importing core-js in entrypoint and use browserlist to select polyfills
useBuiltIns: 'entry',
// Set the corejs version we are using to avoid warnings in console
corejs: 3,
// Exclude transforms that make all code slower
exclude: ['transform-typeof-symbol'],
loose: true,
targets: {
node: 'current',
},
},
];

module.exports = {
presets: [
[
'@babel/preset-react',
{
development: isDevelopment,
},
],
[
'@babel/preset-typescript',
{
isTSX: true,
allExtensions: true,
},
],
envPreset,
],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }],
'@babel/plugin-syntax-dynamic-import',
[
'@babel/plugin-transform-runtime',
{
corejs: false,
helpers: !isDevelopment,
regenerator: !isDevelopment,
useESModules: !isDevelopment,
},
],
],
};
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib/
16 changes: 6 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"airbnb/hooks",
"airbnb-typescript",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand All @@ -21,16 +24,9 @@
},
"ecmaVersion": 2020,
"sourceType": "module",
"tsconfigRootDir": "./tsconfig.json",
"project": true
"tsconfigRootDir": ".",
"project": ["./tsconfig.eslint.json"]
},
"plugins": [
"react",
"react-hooks",
"@typescript-eslint",
"jsx-a11y",
"prettier"
],
"rules": {
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-unused-vars": "off",
Expand Down
23 changes: 16 additions & 7 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
const path = require('path');
const { ESLint } = require('eslint')

const buildEslintCommand = (filenames) =>
`eslint --fix ${filenames
.map((f) => path.relative(process.cwd(), f))
.join(' ')}`;
const removeIgnoredFiles = async (files) => {
const eslint = new ESLint()
const isIgnored = await Promise.all(
files.map((file) => {
return eslint.isPathIgnored(file)
})
)
const filteredFiles = files.filter((_, i) => !isIgnored[i])
return filteredFiles.join(' ')
}

module.exports = {
'*.{js,jsx,ts,tsx}': [buildEslintCommand],
};
'**/*.{ts,tsx,js,jsx}': async (files) => {
const filesToLint = await removeIgnoredFiles(files)
return [`eslint --fix --max-warnings=0 ${filesToLint}`]
},
}
1 change: 0 additions & 1 deletion global.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module.exports = {
'^@components/(.*)$': '<rootDir>/src/components/$1',
'^@styles/(.*)$': '<rootDir>/src/components/styles/$1',
'^@globalStyles/(.*)$': '<rootDir>/src/components/styles/$1',
'\\.(css|less|scss|sss|styl)$': '<rootDir>/__mocks__/styleMock.ts',
'\\.(css|less|scss|sss|styl)$': '<rootDir>/src/__mocks__/styleMock.ts',
},
preset: 'ts-jest',
setupFiles: ['./jest.setup.ts'],
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
testEnvironment: 'jsdom',
testMatch: ['**/__tests__/**/*.[jt]s?(x)'],
testMatch: ['<rootDir>/src/**/*.test.[jt]s?(x)'],
testPathIgnorePatterns: ['<rootDir>/lib/'],
};
Loading