Skip to content
This repository was archived by the owner on Mar 23, 2019. It is now read-only.

Commit 0a187e3

Browse files
authored
Migrate tc-web to neutrino v9 (#157)
* Use material's new typograpghy v2 variants * Fix linting errors * Add required changes after rebasing * Regenerate yarn.lock with node 10 * Nits after rebasing on master
1 parent 2c2fa70 commit 0a187e3

File tree

136 files changed

+4759
-10754
lines changed

Some content is hidden

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

136 files changed

+4759
-10754
lines changed

.eslintrc.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const { Neutrino } = require('neutrino');
1+
const neutrino = require('neutrino');
22

3-
module.exports = Neutrino({ root: __dirname })
4-
.use('.neutrinorc')
5-
.call('eslintrc');
3+
module.exports = neutrino().eslintrc();

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ node_modules
88
/styleguide
99
.coverage
1010
.DS_Store
11+
.eslintcache

.neutrinorc.js

Lines changed: 71 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,67 @@
1-
const { join } = require('path');
21
const merge = require('deepmerge');
32

4-
require('babel-register')({
5-
plugins: [
6-
[require.resolve('babel-plugin-transform-es2015-modules-commonjs'), {
7-
useBuiltIns: true
8-
}],
9-
require.resolve('babel-plugin-transform-object-rest-spread'),
10-
],
11-
cache: false,
12-
});
13-
14-
const theme = require('./src/theme').default;
15-
163
module.exports = {
174
use: [
18-
['neutrino-preset-mozilla-frontend-infra/styleguide', {
19-
components: 'src/components/**/index.jsx',
20-
theme: theme.styleguide,
21-
styles: {
22-
StyleGuide: theme.styleguide.StyleGuide,
23-
},
24-
editorConfig: {
25-
theme: 'material',
26-
},
27-
showUsage: true,
28-
skipComponentsWithoutExample: false,
29-
styleguideComponents: {
30-
Wrapper: join(__dirname, 'src/styleguide/ThemeWrapper.jsx'),
31-
StyleGuideRenderer: join(__dirname, 'src/styleguide/StyleGuideRenderer.jsx'),
5+
['@neutrinojs/airbnb', {
6+
eslint: {
7+
parserOptions: {
8+
ecmaFeatures: {
9+
legacyDecorators: true
10+
}
11+
},
12+
emitWarning: process.env.NODE_ENV === 'development',
13+
baseConfig: {
14+
extends: ['plugin:react/recommended', 'eslint-config-prettier'],
15+
},
16+
envs: ['worker', 'serviceworker'],
17+
plugins: ['prettier'],
18+
rules: {
19+
'react/jsx-wrap-multilines': 'off',
20+
'react/prop-types': 'off',
21+
'react/jsx-one-expression-per-line': 'off',
22+
'react/forbid-prop-types': 'off',
23+
'react/prefer-stateless-function': 'off',
24+
'react/no-access-state-in-setstate': 'off',
25+
'react/destructuring-assignment': 'off',
26+
'babel/no-unused-expressions': 'off',
27+
'import/no-extraneous-dependencies': 'off',
28+
// Specify the maximum length of a line in your program
29+
'max-len': [
30+
'error',
31+
80,
32+
2,
33+
{
34+
ignoreUrls: true,
35+
ignoreComments: false,
36+
ignoreStrings: true,
37+
ignoreTemplateLiterals: true,
38+
},
39+
],
40+
// Allow using class methods with static/non-instance functionality
41+
// React lifecycle methods commonly do not use an instance context for
42+
// anything
43+
'class-methods-use-this': 'off',
44+
// Allow console during development, otherwise throw an error
45+
'no-console': process.env.NODE_ENV === 'development' ? 'off' : 'error',
46+
'prettier/prettier': [
47+
'error',
48+
{
49+
singleQuote: true,
50+
trailingComma: 'es5',
51+
bracketSpacing: true,
52+
jsxBracketSameLine: false,
53+
},
54+
],
55+
'consistent-return': 'off',
56+
'no-shadow': 'off',
57+
'no-return-assign': 'off',
58+
'babel/new-cap': 'off',
59+
'no-mixed-operators': 'off',
60+
},
3261
},
3362
}],
34-
['neutrino-preset-mozilla-frontend-infra/react', {
63+
['@neutrinojs/react', {
64+
publicPath: '/',
3565
html: {
3666
title: process.env.APPLICATION_NAME
3767
},
@@ -52,26 +82,21 @@ module.exports = {
5282
},
5383
},
5484
},
55-
eslint: {
56-
rules: {
57-
// This has been set in the latest Airbnb preset, but has not been
58-
// released yet.
59-
'react/no-did-mount-set-state': 'off',
60-
}
61-
}
85+
env: [
86+
'APPLICATION_NAME',
87+
'LOGIN_STRATEGIES',
88+
'PORT',
89+
'TASKCLUSTER_ROOT_URL',
90+
'GRAPHQL_SUBSCRIPTION_ENDPOINT',
91+
],
92+
babel: {
93+
plugins: [
94+
[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
95+
require.resolve('@babel/plugin-proposal-class-properties'),
96+
],
97+
},
6298
}],
63-
['@neutrinojs/env', [
64-
'NODE_ENV',
65-
'APPLICATION_NAME',
66-
'LOGIN_STRATEGIES',
67-
'TASKCLUSTER_ROOT_URL',
68-
'GRAPHQL_SUBSCRIPTION_ENDPOINT',
69-
]],
7099
(neutrino) => {
71-
if (process.env.NODE_ENV === 'development') {
72-
neutrino.config.devtool('cheap-module-source-map');
73-
}
74-
75100
neutrino.config.node.set('Buffer', true);
76101

77102
// The shell view requires this
@@ -80,7 +105,6 @@ module.exports = {
80105
bindings: 'bindings'
81106
}));
82107

83-
neutrino.config.output.publicPath('/');
84108
neutrino.config.module
85109
.rule('graphql')
86110
.test(/\.graphql$/)

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ node_js:
55
- '10'
66
install:
77
- yarn install --frozen-lockfile
8+
before_install:
9+
- curl -sSfL https://yarnpkg.com/install.sh | bash # Required due to: https://github.com/travis-ci/travis-ci/issues/7951
10+
- export PATH=$HOME/.yarn/bin:$PATH
811
before_script:
912
- export CHROME_BIN=chromium-browser
1013
- export DISPLAY=:99.0

karma.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const neutrino = require('neutrino');
2+
3+
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
4+
5+
module.exports = neutrino().karma();

package.json

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@
44
"private": true,
55
"license": "MPL-2.0",
66
"engines": {
7-
"node": ">=8.0.0",
8-
"yarn": ">=1.3.2"
7+
"node": ">=10.0.0",
8+
"yarn": ">=1.10.0"
99
},
1010
"scripts": {
11-
"build": "yarn create:fragment-matcher && neutrino build --require dotenv/config",
12-
"start": "neutrino start --require dotenv/config",
13-
"test": "neutrino test",
14-
"lint": "neutrino lint",
15-
"precommit": "neutrino stage",
16-
"create:fragment-matcher": "node src/scripts/queryServer",
17-
"styleguide": "neutrino styleguide:start --require dotenv/config"
11+
"build": "yarn create:fragment-matcher && dotenv webpack -- --mode production",
12+
"start": "dotenv webpack-dev-server -- --mode development",
13+
"test": "karma start --single-run",
14+
"lint": "eslint --cache --format codeframe --ext mjs,js,jsx src test",
15+
"create:fragment-matcher": "node src/scripts/queryServer"
1816
},
1917
"dependencies": {
20-
"@material-ui/core": "^1.5.1",
21-
"@material-ui/icons": "^1.1.1",
22-
"@material-ui/lab": "3.0.0-alpha.15",
18+
"@material-ui/core": "^3.0.3",
19+
"@material-ui/icons": "^3.0.1",
20+
"@material-ui/lab": "3.0.0-alpha.19",
2321
"@mozilla-frontend-infra/components": "^1.3.1",
2422
"apollo-cache-inmemory": "^1.2.10",
2523
"apollo-cache-persist": "^0.1.1",
@@ -54,7 +52,7 @@
5452
"markdown-it-highlightjs": "^3.0.0",
5553
"markdown-it-link-attributes": "^2.1.0",
5654
"material-ui-pickers": "^1.0.0-rc.9",
57-
"material-ui-treeview": "^1.1.0",
55+
"material-ui-treeview": "^2.0.1",
5856
"mdi-react": "^4.3.0",
5957
"prop-types": "^15.6.2",
6058
"react": "^16.5.2",
@@ -78,16 +76,26 @@
7876
"ws-shell": "^0.1.5"
7977
},
8078
"devDependencies": {
81-
"@neutrinojs/env": "^8.3.0",
82-
"@neutrinojs/jest": "^8.3.0",
83-
"@neutrinojs/karma": "^8.3.0",
84-
"babel-register": "^6.26.0",
85-
"chai": "^4.1.2",
86-
"dotenv": "^5.0.1",
79+
"@babel/plugin-proposal-class-properties": "^7.1.0",
80+
"@babel/plugin-proposal-decorators": "^7.1.2",
81+
"@neutrinojs/airbnb": "^9.0.0-beta.0",
82+
"@neutrinojs/karma": "^9.0.0-beta.0",
83+
"@neutrinojs/react": "^9.0.0-beta.0",
84+
"chai": "^4.2.0",
85+
"dotenv-cli": "^1.4.0",
86+
"eslint": "^5.6.1",
87+
"eslint-config-prettier": "^3.1.0",
88+
"eslint-plugin-prettier": "^3.0.0",
8789
"graphql-tag": "^2.8.0",
88-
"neutrino": "^8.3.0",
89-
"neutrino-preset-mozilla-frontend-infra": "^4.1.0",
90-
"node-fetch": "^2.2.0"
90+
"karma": "^3.0.0",
91+
"karma-cli": "^1.0.1",
92+
"mocha": "^5.2.0",
93+
"neutrino": "^9.0.0-beta.0",
94+
"node-fetch": "^2.2.0",
95+
"prettier": "^1.14.3",
96+
"webpack": "^4.20.2",
97+
"webpack-cli": "^3.1.2",
98+
"webpack-dev-server": "^3.1.9"
9199
},
92100
"optionalDependencies": {
93101
"bufferutil": "^3.0.5",

src/App/Main.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Fragment } from 'react';
1+
import React, { Component, Fragment } from 'react';
22
import { BrowserRouter, Switch } from 'react-router-dom';
33
import { object } from 'prop-types';
44
import ErrorPanel from '@mozilla-frontend-infra/components/ErrorPanel';

src/App/index.jsx

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { hot } from 'react-hot-loader';
2-
import { Component } from 'react';
2+
import React, { Component } from 'react';
33
import storage from 'localforage';
44
import { ApolloProvider } from 'react-apollo';
55
import { ApolloClient } from 'apollo-client';
@@ -26,37 +26,17 @@ const AUTH_STORE = '@@TASKCLUSTER_WEB_AUTH';
2626

2727
@hot(module)
2828
export default class App extends Component {
29-
authorize = async (user, persist = true) => {
30-
if (persist) {
31-
localStorage.setItem(AUTH_STORE, JSON.stringify(user));
32-
}
33-
34-
this.setState({
35-
auth: {
36-
...this.state.auth,
37-
user,
38-
},
39-
});
40-
};
41-
42-
unauthorize = () => {
43-
localStorage.removeItem(AUTH_STORE);
44-
this.setState({
45-
auth: {
46-
...this.state.auth,
47-
user: null,
48-
},
49-
});
50-
};
51-
5229
fragmentMatcher = new IntrospectionFragmentMatcher({
5330
introspectionQueryResultData,
5431
});
32+
5533
cache = new InMemoryCache({ fragmentMatcher: this.fragmentMatcher });
34+
5635
persistence = new CachePersistor({
5736
cache: this.cache,
5837
storage,
5938
});
39+
6040
apolloClient = new ApolloClient({
6141
cache: this.cache,
6242
link: from([
@@ -121,9 +101,30 @@ export default class App extends Component {
121101
this.state = state;
122102
}
123103

124-
componentDidCatch(error) {
125-
this.setState({ error });
126-
}
104+
authorize = async (user, persist = true) => {
105+
if (persist) {
106+
localStorage.setItem(AUTH_STORE, JSON.stringify(user));
107+
}
108+
109+
this.setState({
110+
auth: {
111+
// eslint-disable-next-line react/no-access-state-in-setstate
112+
...this.state.auth,
113+
user,
114+
},
115+
});
116+
};
117+
118+
unauthorize = () => {
119+
localStorage.removeItem(AUTH_STORE);
120+
this.setState({
121+
auth: {
122+
// eslint-disable-next-line react/no-access-state-in-setstate
123+
...this.state.auth,
124+
user: null,
125+
},
126+
});
127+
};
127128

128129
toggleTheme = () => {
129130
this.setState({
@@ -134,6 +135,10 @@ export default class App extends Component {
134135
});
135136
};
136137

138+
componentDidCatch(error) {
139+
this.setState({ error });
140+
}
141+
137142
render() {
138143
const { auth, error, theme } = this.state;
139144

src/components/AwsProvisionerErrorsTable/index.jsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Fragment, Component } from 'react';
1+
import React, { Component, Fragment } from 'react';
22
import { arrayOf } from 'prop-types';
33
import { pipe, map, sort as rSort } from 'ramda';
44
import memoize from 'fast-memoize';
@@ -38,13 +38,6 @@ export default class AwsProvisionerErrorsTable extends Component {
3838
sortDirection: null,
3939
};
4040

41-
handleHeaderClick = sortBy => {
42-
const toggled = this.state.sortDirection === 'desc' ? 'asc' : 'desc';
43-
const sortDirection = this.state.sortBy === sortBy ? toggled : 'desc';
44-
45-
this.setState({ sortBy, sortDirection });
46-
};
47-
4841
createSortedErrors = memoize(
4942
(errors, sortBy, sortDirection) => {
5043
const sortByProperty = camelCase(sortBy);
@@ -71,6 +64,13 @@ export default class AwsProvisionerErrorsTable extends Component {
7164
}
7265
);
7366

67+
handleHeaderClick = sortBy => {
68+
const toggled = this.state.sortDirection === 'desc' ? 'asc' : 'desc';
69+
const sortDirection = this.state.sortBy === sortBy ? toggled : 'desc';
70+
71+
this.setState({ sortBy, sortDirection });
72+
};
73+
7474
render() {
7575
const { errors } = this.props;
7676
const { sortBy, sortDirection } = this.state;
@@ -97,7 +97,8 @@ export default class AwsProvisionerErrorsTable extends Component {
9797
<TableRow
9898
key={`${error.az}-${error.instanceType}-${error.type}-${
9999
error.time
100-
}`}>
100+
}`}
101+
>
101102
<TableCell>
102103
<Typography>{error.az}</Typography>
103104
</TableCell>

0 commit comments

Comments
 (0)