Skip to content

Commit

Permalink
upgrade eslint, add eslint --fix on save #67
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigura committed Mar 16, 2020
1 parent 2808c80 commit 578baed
Show file tree
Hide file tree
Showing 61 changed files with 1,942 additions and 1,548 deletions.
9 changes: 3 additions & 6 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
blueprints/**/files/**
coverage/**
node_modules/**
dist/**
src/index.html
**/flow_validate_*
coverage/*
node_modules/*
dist/*
165 changes: 136 additions & 29 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"parser": "babel-eslint",
"extends": [
"standard",
"airbnb",
"eslint:recommended",
"plugin:react/recommended",
"plugin:flowtype/recommended"
],
Expand All @@ -10,47 +11,122 @@
"react",
"promise",
"immutable",
"flowtype",
"flowtype"
],
"env": {
"browser" : true,
"browser": true,
"jest": true
},
"globals": {
"__line" : false,
"__DEV__" : false,
"__TEST__" : false,
"__PROD__" : false,
"__COVERAGE__" : false,
"__line": false,
"__DEV__": false,
"__TEST__": false,
"__PROD__": false,
"__COVERAGE__": false,
"$PropertyType": false,
"$Shape": false,
"google": false
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": true
},
"react": {
"version": "detect"
}
"google": false,
"history": false
},
"rules": {
"no-use-before-deinfe" : 0,
"comma-dangle" : ["error", "always-multiline"],
"key-spacing" : 0,
"semi" : [2, "always"],
"jsx-quotes" : [2, "prefer-single"],
"max-len" : [2, 120, 2],
"object-curly-spacing" : [2, "always"],

"import/default": 0,
"import/named": 0,
"import/namespace": 0,
"import/no-named-as-default-member": 0,
"import/no-named-as-default": 0,
"import/order": [
"error",
{
"groups": [
[
"builtin",
"external"
],
[
"internal",
"index"
],
[
"parent"
],
[
"sibling"
]
],
"newlines-between": "always-and-inside-groups"
}
],
"no-plusplus": 0,
"react/jsx-props-no-spreading": 0,
"no-return-assign": 0,
"arrow-parens": ["error", "as-needed"],
"space-before-function-paren": 0,
"lines-between-class-members": 0,
"no-nested-ternary": 0,
"operator-linebreak": [
"error",
"after",
{
"overrides": {
"?": "before",
":": "before"
}
}
],
"no-use-before-deinfe": 0,
"comma-dangle": [
"error",
"always-multiline"
],
"key-spacing": 0,
"semi": [
2,
"always"
],
"jsx-quotes": [
2,
"prefer-single"
],
"max-len": [
2,
120,
2
],
"object-curly-spacing": [
2,
"always"
],
"object-curly-newline": [
"error",
{
"ObjectExpression": {
"multiline": true,
"minProperties": 3
},
"ObjectPattern": {
"multiline": true,
"minProperties": 3
},
"ImportDeclaration": {
"multiline": true,
"minProperties": 3
},
"ExportDeclaration": {
"multiline": true,
"minProperties": 3
}
}
],
"no-unused-expressions": 0,
"no-bitwise": 0,
"react/require-default-props": 0,
"react/jsx-filename-extension": 0,
"react/destructuring-assignment": 1,
"react/no-unused-prop-types": 0, //We use flow
"react/prop-types": 0, //We use flow

/* "immutable/no-let": 2, */
/* "immutable/no-mutation": 2, */
/* "immutable/no-this": 2, */


"flowtype/boolean-style": [
2,
"boolean"
Expand Down Expand Up @@ -100,5 +176,36 @@
],
"flowtype/use-flow-type": 1,
"flowtype/valid-syntax": 1
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": true
},
"react": {
"version": "detect"
},
"import/parser": "babel-eslint",
"import/resolver": {
"node": {
"moduleDirectory": [
"src/server",
"src/client",
"./",
"node_modules"
],
"paths": [
"src/server",
"src/client",
"./",
"node_modules"
]
},
},
"import/extensions": [
".js"
],
"import/ignore": [
"\\.(scss|less|css)$"
]
}
}
}
19 changes: 19 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
[ignore]
.*/compiled

[include]

[libs]

[options]
module.name_mapper='^~/\(.*\)$' -> '<PROJECT_ROOT>/src/client/\1'
module.name_mapper='^{rootPathPrefix}/\(.*\)$' -> '<PROJECT_ROOT>/{rootPathSuffix}/\1'
module.name_mapper='^.*\.css$' -> 'css-module-flow'
module.name_mapper='^.*\.scss$' -> 'css-module-flow'
esproposal.decorators=ignore
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=src/client
module.system.node.resolve_dirname=src/server
module.system=haste
munge_underscores=false
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_type=$FlowExpectedError

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*www[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
14 changes: 4 additions & 10 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
module.exports = {
presets: ['@babel/preset-flow', '@babel/preset-env', '@babel/preset-react'],
plugins: [
['@babel/plugin-proposal-decorators', { 'legacy': true }],
['@babel/plugin-proposal-decorators', { legacy: true }],
'transform-function-bind',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
['babel-plugin-root-import', {
'paths': [
{ 'rootPathSuffix': 'src/client' },
paths: [
{ rootPathSuffix: 'src/client', rootPathPrefix: '' },
],
}],
],
env: {
development: {
plugins: [
'react-hot-loader/babel',
],
},
},
env: { development: { plugins: ['react-hot-loader/babel'] } },
};
26 changes: 9 additions & 17 deletions dev.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ const app = express();
const compiler = webpack(webpackConfig);
const make = (apiAddress) => {
const proxy = apiAddress
? httpProxy.createProxyServer({
target: apiAddress,
}) : httpProxy.createProxyServer();
? httpProxy.createProxyServer({ target: apiAddress })
: httpProxy.createProxyServer();

proxy.on('error', (error, req, res) => {
if (error.code !== 'ECONNRESET') {
Expand All @@ -34,19 +33,15 @@ const register = (app, proxy, path, apiAddress) => {
console.log(`Server ${app.name} will proxy ${path} to ${apiAddress}`);

app.use(path, (req, res) => {
proxy.web(req, res, {
target: apiAddress,
});
proxy.web(req, res, { target: apiAddress });
});
};
const middleware = [
webpackDevMiddleware(compiler, {
port: devPort,
contentBase: path.join(__dirname, 'src', 'client'),
hot: true,
stats: {
colors: true,
},
stats: { colors: true },
compress: true,
}),
webpackHotMiddleware(compiler, {
Expand All @@ -59,9 +54,7 @@ const middleware = [

app.use(middleware);

[
{ address: `http://localhost:${port}/api`, path: '/api' },
].forEach(cfg => {
[{ address: `http://localhost:${port}/api`, path: '/api' }].forEach((cfg) => {
const proxy = make(cfg.address);
app.on('stop', () => proxy.close());
register(app, proxy, cfg.path, cfg.address);
Expand All @@ -83,8 +76,7 @@ app.listen(devPort, () => {
console.log('Developer Server | port: %s', devPort);
});

process
.on('dev server Uncaught Exception', (err) => {
// eslint-disable-next-line no-console
console.error('<!> Exception %s: ', err.message, err.stack);
});
process.on('dev server Uncaught Exception', (err) => {
// eslint-disable-next-line no-console
console.error('<!> Exception %s: ', err.message, err.stack);
});
9 changes: 2 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ module.exports = {
...defaults.transform,
'^.+\\.[t|j]sx?$': '<rootDir>/jest.transform.js',
},
moduleFileExtensions: [
'js',
'jsx',
],
moduleFileExtensions: ['js', 'jsx'],
testEnvironment: 'node',
coveragePathIgnorePatterns: [].concat(
defaults.coveragePathIgnorePatterns,
[]
),
setupFiles: [
'<rootDir>/jest.init.js',
],
setupFiles: ['<rootDir>/jest.init.js'],
verbose: true,
};
11 changes: 11 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"experimentalDecorators": true
},
"exclude": [
"/node_modules/",
"node_modules"
]
}
Loading

0 comments on commit 578baed

Please sign in to comment.