Skip to content

Commit 2515143

Browse files
committed
build: update configuration & dependencies
1 parent 291755a commit 2515143

29 files changed

+14637
-9259
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.babelrc.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const {BUILD_TYPE} = process.env;
2+
const isCjs = BUILD_TYPE === 'cjs';
3+
const isLib = BUILD_TYPE === 'lib';
4+
5+
module.exports = api => ({
6+
plugins: isLib
7+
? []
8+
: [
9+
[
10+
require('babel-plugin-transform-async-to-promises'),
11+
{hoist: true, inlineHelpers: true},
12+
],
13+
[
14+
require('@babel/plugin-transform-runtime'),
15+
{
16+
regenerator: false,
17+
},
18+
],
19+
[require('@babel/plugin-proposal-class-properties'), {loose: true}],
20+
[require('@babel/plugin-proposal-object-rest-spread'), {loose: true}],
21+
],
22+
presets: [
23+
require('@babel/preset-typescript'),
24+
[require('@babel/preset-react'), {useBuiltIns: true}],
25+
...(isLib
26+
? []
27+
: [
28+
[
29+
require('@babel/preset-env'),
30+
{
31+
loose: true,
32+
modules: isCjs ? 'commonjs' : false,
33+
shippedProposals: true,
34+
targets: {
35+
browsers: ['last 2 versions', 'IE 11'],
36+
},
37+
useBuiltIns: false,
38+
},
39+
],
40+
]),
41+
],
42+
...(api.env('test') && {
43+
presets: [
44+
['babel-preset-react-app', {flow: false, typescript: true}],
45+
[
46+
'@babel/preset-env',
47+
{
48+
modules: 'commonjs',
49+
targets: {
50+
node: process.versions.node,
51+
},
52+
},
53+
],
54+
],
55+
}),
56+
});

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/node_modules/**/*
2+
**/dist/**/*
3+
*.ts
4+
*.tsx

.eslintrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": ["eslint-config-poetez", "plugin:prettier/recommended"],
3+
"env": {
4+
"node": true
5+
},
6+
"rules": {
7+
"global-require": "off"
8+
}
9+
}

.lintstagedrc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
{
2-
"linters": {
3-
".storybook/**/*.js": ["npm run lint:storybook -- --fix", "git add"],
4-
"__stories__/**/*.+(ts|tsx)": ["npm run lint:src -- --fix", "node ./scripts/typecheck.js", "git add"],
5-
"__tests__/**/*.+(ts|tsx)": ["npm run lint:src -- --fix", "node ./scripts/typecheck.js", "git add"],
6-
"config/**/*.js": ["npm run lint:config -- --fix", "git add"],
7-
"scripts/**/*.js": ["npm run lint:scripts -- --fix", "git add"],
8-
"src/**/*.+(ts|tsx)": ["npm run lint:src -- --fix", "node ./scripts/typecheck.js", "git add"],
9-
}
2+
"*.js": ["prettier --write", "eslint --fix", "git add"],
3+
"*.+(ts|tsx)": ["prettier --write", "tslint -c tslint.json -p tsconfig.json -t verbose --fix", "git add"]
104
}

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"bracketSpacing": false,
3+
"printWidth": 80,
4+
"trailingComma": "all",
5+
"tabWidth": 2,
6+
"singleQuote": true
7+
}

.storybook/.eslintrc.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

.storybook/config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
const {configure} = require('@storybook/react');
22
const {setOptions} = require('@storybook/addon-options');
33

4-
function loadStories() {
5-
// eslint-disable-next-line import/no-unresolved
6-
require('../__stories__/Tree');
7-
}
4+
const loadStories = () => {
5+
require('../__stories__');
6+
};
87

98
setOptions({
109
downPanelInRight: true,

.storybook/helpers.js

Lines changed: 0 additions & 21 deletions
This file was deleted.

.storybook/webpack.config.js

Lines changed: 8 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,15 @@
1+
/* eslint-disable sort-keys */
12

2-
// you can use this file to add your custom webpack plugins, loaders and anything you like.
3-
// This is just the basic way to add additional webpack configurations.
4-
// For more information refer the docs: https://storybook.js.org/configurations/custom-webpack-config
5-
6-
// IMPORTANT
7-
// When you add this file, we won't add the default configurations which is similar
8-
// to "React Create App". This only has babel loader to load JavaScript.
9-
10-
const path = require('path');
11-
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js');
12-
const {getLocalIdent} = require('./helpers');
13-
const paths = require('../config/paths');
14-
const postcssConfig = require('../config/postcss.config');
15-
const babelConfig = require('../config/babel.config');
16-
17-
module.exports = (baseConfig, env) => {
18-
const config = genDefaultConfig(baseConfig, env);
3+
module.exports = ({config}) => {
194
config.devtool = 'eval';
205

21-
config.module.rules = [
22-
{
23-
test: /\.js$/,
24-
loader: require.resolve('source-map-loader'),
25-
enforce: 'pre',
26-
include: paths.src,
27-
},
28-
{
29-
// "oneOf" will traverse all following loaders until one will
30-
// match the requirements. When no loader matches it will fall
31-
// back to the "file" loader at the end of the loader list.
32-
oneOf: [
33-
{
34-
test: /\.md$/,
35-
loader: 'raw-loader',
36-
},
37-
// "url" loader works like "file" loader except that it embeds assets
38-
// smaller than specified limit in bytes as data URLs to avoid requests.
39-
// A missing `test` is equivalent to a match.
40-
{
41-
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
42-
loader: require.resolve('url-loader'),
43-
options: {
44-
limit: 10000,
45-
name: 'static/media/[name].[hash:8].[ext]',
46-
},
47-
},
48-
// Compile .tsx?
49-
{
50-
test: /\.(ts|tsx)$/,
51-
include: [paths.src, paths.stories],
52-
loader: require.resolve('babel-loader'),
53-
options: {
54-
babelrc: false,
55-
cacheDirectory: path.resolve(process.cwd(), '.cache'),
56-
...babelConfig,
57-
},
58-
},
59-
// "postcss" loader applies autoprefixer to our CSS.
60-
// "css" loader resolves paths in CSS and adds assets as dependencies.
61-
// "style" loader turns CSS into JS modules that inject <style> tags.
62-
// In production, we use a plugin to extract that CSS to a file, but
63-
// in development "style" loader enables hot editing of CSS.
64-
{
65-
test: /\.css$/,
66-
use: [
67-
require.resolve('style-loader'),
68-
{
69-
loader: require.resolve('css-loader'),
70-
options: {
71-
importLoaders: 1,
72-
modules: true,
73-
camelCase: true,
74-
localIdentName: '[name]__[local]',
75-
getLocalIdent,
76-
},
77-
},
78-
{
79-
loader: require.resolve('postcss-loader'),
80-
options: {
81-
// Necessary for external CSS imports to work
82-
// https://github.com/facebookincubator/create-react-app/issues/2677
83-
ident: 'postcss',
84-
plugins: postcssConfig,
85-
},
86-
},
87-
],
88-
},
89-
{
90-
91-
},
92-
// "file" loader makes sure those assets get served by WebpackDevServer.
93-
// When you `import` an asset, you get its (virtual) filename.
94-
// In production, they would get copied to the `build` folder.
95-
// This loader don't uses a "test" so it will catch all modules
96-
// that fall through the other loaders.
97-
{
98-
// Exclude `js` files to keep "css" loader working as it injects
99-
// it's runtime that would otherwise processed through "file" loader.
100-
// Also exclude `html` and `json` extensions so they get processed
101-
// by webpacks internal loaders.
102-
exclude: [/\.js$/, /\.html$/, /\.json$/],
103-
loader: require.resolve('file-loader'),
104-
options: {
105-
name: 'static/media/[name].[hash:8].[ext]',
106-
},
107-
},
108-
],
6+
config.module.rules.push({
7+
test: /\.(ts|tsx)$/,
8+
loader: require.resolve('babel-loader'),
9+
options: {
10+
presets: [['babel-preset-react-app', {flow: false, typescript: true}]],
10911
},
110-
// ** STOP ** Are you adding a new loader?
111-
// Make sure to add the new loader(s) before the "file" loader.
112-
];
12+
});
11313

11414
config.resolve.extensions.push('.ts', '.tsx');
11515

0 commit comments

Comments
 (0)