Skip to content

Commit

Permalink
Update ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
th0r committed Jan 31, 2018
1 parent 9d4509b commit 74dd573
Show file tree
Hide file tree
Showing 7 changed files with 406 additions and 242 deletions.
25 changes: 22 additions & 3 deletions .eslintrc.json
Expand Up @@ -22,13 +22,17 @@
"consistent-return": 0,
"eol-last": 0,
"func-call-spacing": [2, "never"],
"function-paren-newline": 0,
"for-direction": 2,
"new-parens": 0,
"newline-per-chained-call": [2, {"ignoreChainWithDepth": 2}],
"no-alert": 0,
"no-await-in-loop": 0,
"no-catch-shadow": 0,
"no-class-assign": 0,
"no-compare-neg-zero": 2,
"no-console": 0,
"no-confusing-arrow": [2, {"allowParens": true}],
"no-extra-parens": 0,
"no-labels": 0,
"no-lone-blocks": 0,
Expand All @@ -45,38 +49,52 @@
"no-useless-computed-key": 2,
"no-useless-escape": 2,
"no-useless-rename": 2,
"padding-line-between-statements": [
2,
{"blankLine": "always", "prev": "directive", "next": "*"}
],
"prefer-destructuring": [2, {
"array": false,
"object": true
}],
"prefer-reflect": 0,
"quote-props": 0,
"semi-spacing": 0,
"semi-style": [2, "last"],
"space-unary-ops": 0,
"strict": 0,
"symbol-description": 2,
"switch-colon-spacing": 2,
"array-bracket-spacing": [2, "never"],
"array-bracket-newline": [2, "consistent"],
"array-callback-return": [2, {"allowImplicit": false}],
"arrow-spacing": [2, {"before": true, "after": true}],
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
"camelcase": [2, {"properties": "never"}],
"comma-dangle": [2, "never"],
"comma-spacing": [2, {"before": false, "after": true}],
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-notation": [2, {"allowKeywords": true, "allowPattern": "^[a-z]+(_[a-z]+)+$"}],
"eqeqeq": [2, "allow-null"],
"generator-star-spacing": [2, "after"],
"getter-return": 2,
"handle-callback-err": 2,
"indent": [2, 2, {"SwitchCase": 1}],
"indent": [2, 2, {
"SwitchCase": 1,
"ignoredNodes": ["TemplateLiteral"]
}],
"key-spacing": [1, {"beforeColon": false, "afterColon": true}],
"keyword-spacing": 2,
"linebreak-style": [2, "unix"],
"line-comment-position": [2, {"position": "above"}],
"lines-around-directive": 2,
"lines-between-class-members": [2, "always", {"exceptAfterSingleLine": true}],
"max-len": [2, {"code": 120, "tabWidth": 4}],
"new-cap": [2, {"newIsCap": true, "capIsNew": false}],
"nonblock-statement-body-position": ["error", "beside"],
"no-array-constructor": 2,
"no-buffer-constructor": 2,
"no-caller": 2,
"no-case-declarations": 2,
"no-cond-assign": [2, "except-parens"],
Expand Down Expand Up @@ -142,7 +160,8 @@
"no-with": 2,
"one-var": [2, "never"],
"object-curly-spacing": [2, "always"],
"object-curly-newline": 0,
"object-curly-newline": [2, {"consistent": true}],
"object-property-newline": [2, {"allowAllPropertiesOnSameLine": true}],
"object-shorthand": [2, "always"],
"prefer-const": [2, {"destructuring": "all"}],
"prefer-numeric-literals": 2,
Expand Down
26 changes: 21 additions & 5 deletions client/.eslintrc.json
Expand Up @@ -13,10 +13,16 @@
"react"
],
"rules": {
"react/boolean-prop-naming": 0,
"react/button-has-type": 2,
"react/display-name": 1,
"react/default-props-match-prop-types": 2,
"react/destructuring-assignment": 0,
"react/forbid-component-props": 0,
"react/forbid-elements": 0,
"react/forbid-foreign-prop-types": 2,
"react/forbid-prop-types": 0,
"react/no-access-state-in-setstate": 0,
"react/no-array-index-key": 2,
"react/no-children-prop": 2,
"react/no-danger": 0,
Expand All @@ -28,18 +34,22 @@
"react/no-find-dom-node": 2,
"react/no-is-mounted": 2,
"react/no-multi-comp": 2,
"react/no-redundant-should-component-update": 2,
"react/no-render-return-value": 2,
"react/no-set-state": 0,
"react/no-string-refs": 0,
"react/no-this-in-sfc": 2,
"react/no-typos": 2,
"react/no-unescaped-entities": 0,
"react/no-unknown-property": 2,
"react/no-unused-prop-types": 2,
"react/no-unused-state": 2,
"react/no-will-update-set-state": 2,
"react/prefer-es6-class": 2,
"react/prefer-stateless-function": 0,
"react/prop-types": 0,
"react/react-in-jsx-scope": 1,
"react/require-default-props": 2,
"react/require-default-props": [2, {"forbidDefaultForRequired": true}],
"react/require-optimization": 0,
"react/require-render-return": 2,
"react/self-closing-comp": 2,
Expand Down Expand Up @@ -87,6 +97,8 @@
"react/void-dom-elements-no-children": 2,
"react/jsx-boolean-value": [2, "never"],
"react/jsx-closing-bracket-location": [2, "after-props"],
"react/jsx-closing-tag-location": 2,
"react/jsx-curly-brace-presence": [2, "never"],
"react/jsx-curly-spacing": [2, "never"],
"react/jsx-equals-spacing": [2, "never"],
"react/jsx-filename-extension": [2, {"extensions": [".jsx"]}],
Expand All @@ -106,6 +118,7 @@
"react/jsx-no-target-blank": 2,
"react/jsx-no-undef": 2,
"react/jsx-pascal-case": 2,
"react/jsx-sort-default-props": 0,
"react/jsx-sort-props": [2, {
"callbacksLast": true,
"shorthandLast": true,
Expand All @@ -121,10 +134,13 @@
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/jsx-wrap-multilines": [2, {
"declaration": true,
"assignment": true,
"return": true,
"arrow": false
"declaration": "parens-new-line",
"assignment": "parens-new-line",
"return": "parens-new-line",
"arrow": "ignore",
"condition": "ignore",
"logical": "ignore",
"prop": "ignore"
}]
}
}
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -48,7 +48,7 @@
},
"devDependencies": {
"babel-core": "6.26.0",
"babel-eslint": "7.2.3",
"babel-eslint": "8.2.1",
"babel-loader": "7.1.2",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.26.0",
Expand All @@ -59,8 +59,8 @@
"classnames": "2.2.5",
"css-loader": "0.28.9",
"del": "3.0.0",
"eslint": "3.19.0",
"eslint-plugin-react": "7.0.0",
"eslint": "4.16.0",
"eslint-plugin-react": "7.6.1",
"exports-loader": "0.6.4",
"gulp": "4.0.0",
"gulp-babel": "7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/analyzer.js
Expand Up @@ -141,7 +141,7 @@ function getModulePath(module) {
// Removing first `.`
.slice(1)
// Replacing `~` with `node_modules`
.map(part => (part === '~') ? 'node_modules' : part);
.map(part => (part === '~' ? 'node_modules' : part));

return parsedPath.length ? parsedPath : null;
}
2 changes: 1 addition & 1 deletion test/helpers.js
Expand Up @@ -12,7 +12,7 @@ const BundleAnalyzerPlugin = require('../lib/BundleAnalyzerPlugin');

function webpackCompile(config) {
return new Promise((resolve, reject) =>
webpack(config, err => err ? reject(err) : resolve())
webpack(config, err => (err ? reject(err) : resolve()))
);
}

Expand Down
80 changes: 41 additions & 39 deletions test/viewer.js
Expand Up @@ -16,51 +16,53 @@ describe('WebSocket server', function () {
port: 0
};

startServer(bundleStats, options).then(function ({ http: server }) {
// The GUID constant defined in WebSocket protocol
// https://tools.ietf.org/html/rfc6455#section-1.3
const GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
startServer(bundleStats, options)
.then(function ({ http: server }) {
// The GUID constant defined in WebSocket protocol
// https://tools.ietf.org/html/rfc6455#section-1.3
const GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';

// The client-generated "Sec-WebSocket-Key" header field value.
const key = crypto.randomBytes(16).toString('base64');
// The client-generated "Sec-WebSocket-Key" header field value.
const key = crypto.randomBytes(16).toString('base64');

// The server-generated "Sec-WebSocket-Accept" header field value.
const accept = crypto.createHash('sha1')
.update(key + GUID)
.digest('base64');
// The server-generated "Sec-WebSocket-Accept" header field value.
const accept = crypto.createHash('sha1')
.update(key + GUID)
.digest('base64');

const socket = net.createConnection(server.address().port, function () {
socket.write([
'GET / HTTP/1.1',
'Host: localhost',
'Upgrade: websocket',
'Connection: Upgrade',
`Sec-WebSocket-Key: ${key}`,
'Sec-WebSocket-Version: 13',
'',
''
].join('\r\n'));
});
const socket = net.createConnection(server.address().port, function () {
socket.write([
'GET / HTTP/1.1',
'Host: localhost',
'Upgrade: websocket',
'Connection: Upgrade',
`Sec-WebSocket-Key: ${key}`,
'Sec-WebSocket-Version: 13',
'',
''
].join('\r\n'));
});

socket.on('data', function (chunk) {
const expected = Buffer.from([
'HTTP/1.1 101 Switching Protocols',
'Upgrade: websocket',
'Connection: Upgrade',
`Sec-WebSocket-Accept: ${accept}`,
'',
''
].join('\r\n'));
socket.on('data', function (chunk) {
const expected = Buffer.from([
'HTTP/1.1 101 Switching Protocols',
'Upgrade: websocket',
'Connection: Upgrade',
`Sec-WebSocket-Accept: ${accept}`,
'',
''
].join('\r\n'));

expect(chunk.equals(expected)).to.be.true;
expect(chunk.equals(expected)).to.be.true;

// Send a WebSocket frame with a reserved opcode (5) to trigger an error
// to be emitted on the server.
socket.write(Buffer.from([0x85, 0x00]));
socket.on('close', function () {
server.close(done);
// Send a WebSocket frame with a reserved opcode (5) to trigger an error
// to be emitted on the server.
socket.write(Buffer.from([0x85, 0x00]));
socket.on('close', function () {
server.close(done);
});
});
});
}).catch(done);
})
.catch(done);
});
});

0 comments on commit 74dd573

Please sign in to comment.