Skip to content

Commit

Permalink
Typescript Rework (mattermost#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
reflog authored Oct 16, 2019
1 parent 3bb89a5 commit 4727841
Show file tree
Hide file tree
Showing 253 changed files with 5,878 additions and 10,388 deletions.
34 changes: 16 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,43 @@ executors:
docker:
- image: circleci/node:11.3.0

aliases:
- &restore_cache
restore_cache:
key: dependencies-{{ checksum "package-lock.json" }}
- &save_cache
save_cache:
key: dependencies-{{ checksum "package-lock.json" }}
paths:
- node_modules

jobs:
install:
executor:
name: default
steps:
- checkout
- run: ls -la
- restore_cache:
keys:
- test-dependencies-{{ checksum "package.json" }}

- run: npm install --ignore-scripts
- run: npm run flow-typed install
- *restore_cache
- run: npm install
- run: ls -la
- save_cache:
paths:
- node_modules
- flow-typed
key: test-dependencies-{{ checksum "package.json" }}
- *save_cache

lint:
executor:
name: default
steps:
- checkout
- restore_cache:
keys:
- test-dependencies-{{ checksum "package.json" }}
- *restore_cache
- run: npm run check
- run: npm run flow
- run: npm run tsc

test:
executor:
name: default
steps:
- checkout
- restore_cache:
keys:
- test-dependencies-{{ checksum "package.json" }}
- *restore_cache
- run: npm test
- store_test_results:
path: build/
Expand Down
61 changes: 44 additions & 17 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,47 @@
{
"extends": [
"./node_modules/eslint-config-mattermost/.eslintrc.json",
"plugin:flowtype/recommended"
],
"env": {
"jest": true
},
"plugins": [
"flowtype"
],
"overrides": [
{
"files": ["*.test.js"],
"env": {
"extends": [
"./node_modules/eslint-config-mattermost/.eslintrc.json",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"env": {
"jest": true
}
}
]
},
"rules": {
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/no-undefined": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"no-prototype-builtins": 0,
"no-mixed-operators": 0,
"no-undefined": 0,
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "function",
"next": "function"
}
],
"no-nested-ternary": 0,
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-use-before-define": 0,
"max-lines": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/explicit-function-return-type": 0
},
"overrides": [
{
"files": [
"*.test.js"
],
"env": {
"jest": true
}
}
]
}
33 changes: 0 additions & 33 deletions .flowconfig

This file was deleted.

13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ mattermost-redux-*.tgz

# test coverage
coverage
/.rts2_cache_cjs/
/.rts2_cache_esm/
/dist/
/build/
/tsconfig.tsbuildinfo
junit.xml
index.d.ts
index.js
index.js.map
mattermost.client4.js
mattermost.client4.js.map
mattermost.websocket_client.js
mattermost.websocket_client.js.map
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ PULL_REQUEST_TEMPLATE.md
.npmignore
.npminstall
.tmp
src
.circleci
jest.config.js
babel.config.js
rollup.config.js
tsconfig.json
.editorconfig
.eslintignore
mattermost-redux.iml
.eslintrc.json
26 changes: 3 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,13 @@ clean:
pre-run:
@echo Make sure no previous build are in the folder

@rm -rf actions
@rm -rf action_types
@rm -rf client
@rm -rf constants
@rm -rf reducers
@rm -rf selectors
@rm -rf store
@rm -rf utils
@rm -rf lib

test: check-style flow
npm test

flow: .flowinstall
@echo Checking types

npm run flow
@rm -rf build/*

.flowinstall: node_modules
@echo Getting flow-typed packages

npm run flow-typed install
test: check-style
npm test

touch $@

install: node_modules

bundle:
npm run build
npm run webpack
5 changes: 4 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ const config = {
useBuiltIns: 'usage',
shippedProposals: true,
}],
'@babel/typescript',
],
plugins: [
'@babel/transform-flow-comments',
'@babel/plugin-transform-runtime',
'@babel/plugin-syntax-dynamic-import',
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
'@babel/plugin-proposal-optional-chaining',
['module-resolver', {
root: ['./src', '.'],
Expand Down
1 change: 0 additions & 1 deletion build/.gitignore

This file was deleted.

47 changes: 47 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

module.exports = {
globals: {
'ts-jest': {
tsConfig: 'tsconfig.json',
diagnostics: true,
},
NODE_ENV: 'test',
},
preset: 'ts-jest/presets/js-with-babel',
rootDir: '.',
moduleDirectories: ['node_modules', 'src'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
transformIgnorePatterns: ['<rootDir>/node_modules/'],
testMatch: [
'<rootDir>/src/**/?(*.)(spec|test).(ts|js)?(x)',
],
setupFilesAfterEnv: [
'<rootDir>/test/setup.js',
],
clearMocks: true,
collectCoverageFrom: [
'src/**/*.{js}',
'src/**/*.{ts}',
],
coverageReporters: [
'lcov',
'text-summary',
],
reporters: [
'default',
'jest-junit',
],
verbose: true,
moduleNameMapper: {
'^src/(.*)$': '<rootDir>/src/$1',
'^test/(.*)$': '<rootDir>/test/$1',
'^utils/(.*)$': '<rootDir>/src/utils/$1',
'^actions/(.*)$': '<rootDir>/src/actions/$1',
'^action_types$': '<rootDir>/src/action_types',
'^constants$': '<rootDir>/src/constants',
'^action_types/(.*)$': '<rootDir>/src/action_types/$1',
'^@/(.*)$': '<rootDir>/src/$1',
},
};
Loading

0 comments on commit 4727841

Please sign in to comment.