Merge pull request #91 from Mavrin/master
Adds eslint check and fixes linting issues
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ ADD web /srv/web
|
||||
RUN apk add --no-cache --update git
|
||||
RUN \
|
||||
cd /srv/web && \
|
||||
npm i && npm run build && \
|
||||
npm i && npm run lint && npm run build && \
|
||||
rm -rf ./node_modules
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
module.exports = {
|
||||
parser: 'babel-eslint',
|
||||
extends: 'eslint:recommended',
|
||||
plugins: [
|
||||
'react',
|
||||
],
|
||||
env: {
|
||||
browser: true,
|
||||
node: true,
|
||||
es6: true,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
modules: true,
|
||||
jsx: true,
|
||||
}
|
||||
},
|
||||
globals: {
|
||||
remark_config: true,
|
||||
b: true,
|
||||
},
|
||||
rules: {
|
||||
'react/jsx-uses-react': 2,
|
||||
'react/jsx-uses-vars': 2,
|
||||
'no-unused-vars': [1, {varsIgnorePattern: '^h$'}],
|
||||
'no-cond-assign': 1,
|
||||
'no-empty': 0,
|
||||
'no-console': 1,
|
||||
semi: 2,
|
||||
camelcase: 0,
|
||||
'comma-style': 2,
|
||||
indent: [2, 2, {SwitchCase: 1}],
|
||||
'no-mixed-spaces-and-tabs': [2, 'smart-tabs'],
|
||||
'no-trailing-spaces': [2, {skipBlankLines: true}],
|
||||
'max-nested-callbacks': [2, 3],
|
||||
'no-eval': 2,
|
||||
'no-implied-eval': 2,
|
||||
'no-new-func': 2,
|
||||
'guard-for-in': 0,
|
||||
eqeqeq: 0,
|
||||
'no-else-return': 2,
|
||||
'no-redeclare': 2,
|
||||
'no-dupe-keys': 2,
|
||||
radix: 2,
|
||||
strict: [2, 'never'],
|
||||
'no-shadow': 0,
|
||||
'callback-return': [1, ['callback', 'cb', 'next', 'done']],
|
||||
'no-delete-var': 2,
|
||||
'no-undef-init': 2,
|
||||
'no-shadow-restricted-names': 2,
|
||||
'handle-callback-err': 0,
|
||||
'no-lonely-if': 2,
|
||||
'keyword-spacing': 2,
|
||||
'constructor-super': 2,
|
||||
'no-this-before-super': 2,
|
||||
'no-dupe-class-members': 2,
|
||||
'no-const-assign': 2,
|
||||
'prefer-spread': 2,
|
||||
'no-useless-concat': 2,
|
||||
'no-var': 2,
|
||||
'object-shorthand': 2,
|
||||
'prefer-arrow-callback': 2,
|
||||
},
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { siteId, url } from './settings';
|
||||
|
||||
import fetcher from './fetcher'
|
||||
import fetcher from './fetcher';
|
||||
|
||||
// TODO: rename actions
|
||||
|
||||
@@ -22,7 +22,7 @@ export const counts = ({ urls, siteId }) => fetcher.post({
|
||||
|
||||
export const getComment = ({ id }) => fetcher.get(`/id/${id}?url=${url}`);
|
||||
|
||||
export const getUserComments = ({ user, limit }) => fetcher.get(`/comments?user=${user}&limit=${limit}`)
|
||||
export const getUserComments = ({ user, limit }) => fetcher.get(`/comments?user=${user}&limit=${limit}`);
|
||||
|
||||
export const vote = ({ id, url, value }) => fetcher.put({
|
||||
url: `/vote/${id}?url=${url}&vote=${value}`,
|
||||
|
||||
@@ -44,7 +44,7 @@ methods.forEach(method => {
|
||||
.then(res => resolve(res.data))
|
||||
.catch(error => reject(error));
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
export default fetcher;
|
||||
|
||||
@@ -4,7 +4,7 @@ if (!Element.prototype.matches)
|
||||
|
||||
if (!Element.prototype.closest)
|
||||
Element.prototype.closest = function(s) {
|
||||
var el = this;
|
||||
let el = this;
|
||||
if (!document.documentElement.contains(el)) return null;
|
||||
do {
|
||||
if (el.matches(s)) return el;
|
||||
|
||||
@@ -50,7 +50,7 @@ class Store {
|
||||
again = false;
|
||||
|
||||
return root;
|
||||
}
|
||||
};
|
||||
|
||||
const paste = (root, commentObj) => {
|
||||
if (!again) return root;
|
||||
@@ -63,10 +63,9 @@ class Store {
|
||||
root.replies = root.replies.map(reply => {
|
||||
if (reply.comment.id === commentObj.comment.pid) {
|
||||
return concatReply(reply, commentObj);
|
||||
} else {
|
||||
return paste(reply, commentObj);
|
||||
}
|
||||
})
|
||||
return paste(reply, commentObj);
|
||||
});
|
||||
}
|
||||
|
||||
return root;
|
||||
|
||||
@@ -24,9 +24,7 @@ export default class AuthPanel extends Component {
|
||||
toggleBlockedVisibility() {
|
||||
if (!this.state.isBlockedVisible) {
|
||||
if (this.props.onBlockedUsersShow) this.props.onBlockedUsersShow();
|
||||
} else {
|
||||
if (this.props.onBlockedUsersHide) this.props.onBlockedUsersHide();
|
||||
}
|
||||
} else if (this.props.onBlockedUsersHide) this.props.onBlockedUsersHide();
|
||||
|
||||
this.setState({ isBlockedVisible: !this.state.isBlockedVisible });
|
||||
}
|
||||
@@ -70,7 +68,7 @@ export default class AuthPanel extends Component {
|
||||
onClick={() => props.onSignIn(provider)}
|
||||
>{PROVIDER_NAMES[provider]}</span>
|
||||
</span>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
{'.'}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { h, Component } from 'preact';
|
||||
|
||||
import api from 'common/api'
|
||||
import api from 'common/api';
|
||||
|
||||
export default class BlockedUsers extends Component {
|
||||
constructor(props) {
|
||||
@@ -8,7 +8,7 @@ export default class BlockedUsers extends Component {
|
||||
|
||||
this.state = {
|
||||
unblockedUsers: [],
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
block(user) {
|
||||
@@ -73,7 +73,7 @@ export default class BlockedUsers extends Component {
|
||||
)
|
||||
}
|
||||
</li>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
</ul>
|
||||
|
||||
@@ -331,8 +331,8 @@ export default class Comment extends Component {
|
||||
? 'This user was blocked'
|
||||
: (
|
||||
deleted
|
||||
? 'This comment was deleted'
|
||||
: data.text
|
||||
? 'This comment was deleted'
|
||||
: data.text
|
||||
)
|
||||
),
|
||||
time: formatTime(new Date(data.time)),
|
||||
|
||||
@@ -22,7 +22,7 @@ export default class Root extends Component {
|
||||
|
||||
try {
|
||||
sort = localStorage.getItem(LS_SORT_KEY) || DEFAULT_SORT;
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
sort = DEFAULT_SORT;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ export default class Root extends Component {
|
||||
store.set('user', user);
|
||||
this.setState({ user });
|
||||
})
|
||||
.catch(() => {}) // TODO: we need to handle it and write error to user
|
||||
.catch(() => {}); // TODO: we need to handle it and write error to user
|
||||
}
|
||||
}, checkMsDelay);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ export default class Root extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
render({}, { config = {}, comments = [], user, sort, isLoaded, isBlockedVisible, isCommentsListLoading, bannedUsers, commentsShown }) {
|
||||
render(props, { config = {}, comments = [], user, sort, isLoaded, isBlockedVisible, isCommentsListLoading, bannedUsers, commentsShown }) {
|
||||
if (!isLoaded) {
|
||||
return (
|
||||
<div id={NODE_ID}>
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import { COUNTER_NODE_CLASSNAME } from './common/constants'
|
||||
import { COUNTER_NODE_CLASSNAME } from './common/constants';
|
||||
|
||||
import api from 'common/api';
|
||||
|
||||
@@ -17,7 +17,7 @@ function init() {
|
||||
}
|
||||
|
||||
try {
|
||||
remark_config = remark_config || {}
|
||||
remark_config = remark_config || {};
|
||||
} catch (e) {
|
||||
console.error('Remark42: Config object is undefined.');
|
||||
return;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ function init() {
|
||||
}
|
||||
|
||||
try {
|
||||
remark_config = remark_config || {}
|
||||
remark_config = remark_config || {};
|
||||
} catch (e) {
|
||||
console.error('Remark42: Config object is undefined.');
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { h, render } from 'preact';
|
||||
|
||||
import { BASE_URL, DEFAULT_LAST_COMMENTS_MAX, LAST_COMMENTS_NODE_CLASSNAME } from './common/constants'
|
||||
import { BASE_URL, DEFAULT_LAST_COMMENTS_MAX, LAST_COMMENTS_NODE_CLASSNAME } from './common/constants';
|
||||
|
||||
import api from 'common/api';
|
||||
|
||||
@@ -21,7 +21,7 @@ function init() {
|
||||
}
|
||||
|
||||
try {
|
||||
remark_config = remark_config || {}
|
||||
remark_config = remark_config || {};
|
||||
} catch (e) {
|
||||
console.error('Remark42: Config object is undefined.');
|
||||
return;
|
||||
@@ -42,7 +42,7 @@ function init() {
|
||||
api.last({ max, siteId: remark_config.site_id })
|
||||
.then(comments => {
|
||||
try {
|
||||
render(<ListComments comments={comments}/>, node)
|
||||
render(<ListComments comments={comments}/>, node);
|
||||
} catch (e) {
|
||||
console.error('Remark42: Something went wrong with last comments rendering');
|
||||
console.error(e);
|
||||
|
||||
Generated
+2744
-3306
File diff suppressed because it is too large
Load Diff
+5
-1
@@ -4,11 +4,13 @@
|
||||
"scripts": {
|
||||
"build": "NODE_ENV=production webpack --config ./webpack.config.js",
|
||||
"start": "webpack-dev-server --progress --hot --inline --config ./webpack.config.js",
|
||||
"reinstall": "rm -rf ./node_modules/ && npm install"
|
||||
"reinstall": "rm -rf ./node_modules/ && npm install",
|
||||
"lint": "eslint --ext=.js,.jsx ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^7.1.1",
|
||||
"babel-core": "^6.24.1",
|
||||
"babel-eslint": "^8.2.4",
|
||||
"babel-loader": "^7.0.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-plugin-transform-react-jsx": "^6.24.1",
|
||||
@@ -16,6 +18,8 @@
|
||||
"clean-webpack-plugin": "^0.1.16",
|
||||
"copy-webpack-plugin": "^4.5.1",
|
||||
"css-loader": "^0.28.0",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-plugin-react": "^7.9.1",
|
||||
"extract-text-webpack-plugin": "^3.0.0",
|
||||
"file-loader": "^0.11.1",
|
||||
"html-webpack-plugin": "^2.30.1",
|
||||
|
||||
Reference in New Issue
Block a user