Skip to content

Commit c2ebde9

Browse files
authored
refactor(v2): add flowtype + refactor test (#1443)
* chore(v2): add flow setup * nits * fix * add flow-typed * ignore compiled library * fix error * fix typing * fix module name mapper * setup for @docusaurus/core * dont try remove type without @flow * fix can't find @docusaurus/utils * fix test * remove obscure relative paths * more refactoring * add typing for server/load/theme.js * no need to ship .flow source
1 parent 6f011d8 commit c2ebde9

File tree

103 files changed

+8909
-1597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+8909
-1597
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
- run:
4242
name: Check ESLint
4343
command: yarn lint
44+
- run:
45+
name: Check Flow
46+
command: yarn flow check
4447
- run:
4548
name: Check Prettier
4649
command: yarn prettier:diff

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ scripts
1010
packages/docusaurus-1.x/lib/core/metadata.js
1111
packages/docusaurus-1.x/lib/core/MetadataBlog.js
1212
packages/docusaurus-1.x/lib/core/__tests__/split-tab.test.js
13+
packages/docusaurus-utils/lib
14+
packages/docusaurus/lib

.flowconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[ignore]
2+
<PROJECT_ROOT>/packages/.*/lib
3+
<PROJECT_ROOT>/packages/.*/__tests__
4+
5+
[include]
6+
7+
[libs]
8+
9+
[lints]
10+
11+
[options]
12+
module.name_mapper='^@docusaurus\/\([a-zA-Z0-9_\-]+\)$' -> '<PROJECT_ROOT>/packages/docusaurus-\1/src/index'
13+
14+
[strict]

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ yarn-error.log
1111
build
1212
.docusaurus
1313
.cache-loader
14+
packages/docusaurus-utils/lib
15+
packages/docusaurus/lib/
16+

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
dist
22
node_modules
33
build
4-
.docusaurus
4+
.docusaurus
5+
packages/docusaurus-utils/lib
6+
packages/docusaurus/lib
7+
flow-typed

babel.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@
66
*/
77

88
module.exports = {
9-
presets: ['@babel/env', '@babel/react'],
9+
presets: [
10+
[
11+
'@babel/env',
12+
{
13+
targets: {
14+
node: 'current',
15+
},
16+
},
17+
],
18+
'@babel/react',
19+
'@babel/preset-flow',
20+
],
1021
plugins: [
1122
'@babel/plugin-proposal-class-properties',
1223
'@babel/plugin-proposal-object-rest-spread',

jest.transform.js renamed to flow-typed/npm/escape-string-regexp_v1.x.x.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
const babelConfig = require('./babel.config');
9-
10-
module.exports = require('babel-jest').createTransformer(babelConfig);
8+
declare module 'escape-string-regexp' {
9+
declare module.exports: (input: string) => string;
10+
}

0 commit comments

Comments
 (0)