Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Update linting settings
Browse files Browse the repository at this point in the history
  • Loading branch information
tdemin committed Nov 25, 2019
1 parent 69a4710 commit fbc2ae4
Show file tree
Hide file tree
Showing 16 changed files with 349 additions and 210 deletions.
173 changes: 145 additions & 28 deletions .eslintrc.json
@@ -1,28 +1,145 @@
{
"extends": "react-app",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"semi": "error",
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"quotes": ["warn", "double"],
"max-len": [
"error",
{
"code": 80,
"tabWidth": 4
}
]
}
}
{
// Thanks, BoresXP@github.com !
// https://gist.github.com/BoresXP/e404f16a0e153eeb6ce15ce06848f36e
"extends": ["react-app"],
"parserOptions": {
"project": "tsconfig.json",
"tsconfigRootDir": ".",
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"plugins": ["react", "@typescript-eslint"],
"rules": {
"semi": "error",
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"quotes": ["warn", "double"],
"max-len": [
"error",
{
"code": 80,
"tabWidth": 4
}
],
"no-shadow": ["error", { "builtinGlobals": false }],
"no-duplicate-imports": ["error", { "includeExports": true }],
"no-template-curly-in-string": "error",
"block-scoped-var": "error",
"curly": ["error", "all"],
"eqeqeq": "error",
"max-classes-per-file": ["error", 2],
"no-alert": "warn",
"no-console": "warn",
"no-else-return": ["error", { "allowElseIf": false }],
"no-implicit-coercion": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-multi-spaces": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-return-await": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-throw-literal": "error",
"no-unused-expressions": "error",
"no-useless-call": "error",
"no-useless-concat": "error",
"no-useless-return": "error",
"prefer-promise-reject-errors": "error",
"no-undefined": "error",
"array-bracket-newline": ["error", { "multiline": true }],
"comma-dangle": ["error", "always-multiline"],
"comma-style": "error",
"eol-last": "error",
"key-spacing": "error",
"keyword-spacing": "error",
"new-parens": "error",
"no-bitwise": "warn",
"no-lonely-if": "warn",
"no-multiple-empty-lines": "error",
"no-nested-ternary": "error",
"no-new-object": "error",
"no-tabs": ["error", { "allowIndentationTabs": true }],
"no-trailing-spaces": "error",
"no-unneeded-ternary": "error",
"no-whitespace-before-property": "error",
"object-curly-newline": "error",
"object-curly-spacing": ["error", "always"],
"semi-spacing": "error",
"space-before-blocks": "error",
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}
],
"space-in-parens": "error",
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": ["error", "always"],
"switch-colon-spacing": "error",
"arrow-body-style": ["error", "as-needed"],
"arrow-parens": ["error", "always"],
"arrow-spacing": "error",
"generator-star-spacing": ["error", "after"],
"no-confusing-arrow": "error",
"no-useless-computed-key": "error",
"no-useless-rename": "error",
"object-shorthand": ["error", "always"],
"prefer-arrow-callback": "warn",
"prefer-destructuring": "error",
"rest-spread-spacing": ["error", "never"],
"template-curly-spacing": "error",
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/member-ordering": "warn",
"@typescript-eslint/no-magic-numbers": [
"error",
{
"ignoreNumericLiteralTypes": true,
"ignoreEnums": true,
"enforceConst": true,
"ignoreReadonlyClassProperties": true,
"ignore": [0, 1, 2]
}
],
"@typescript-eslint/brace-style": ["error", "1tbs"],
"@typescript-eslint/quotes": [
"error",
"double",
{ "avoidEscape": true }
],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/no-parameter-properties": "error",
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-readonly": "warn",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/camelcase": ["error", { "properties": "never" }],
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_$" }
],
"react/no-access-state-in-setstate": "error",
"react/no-danger": "error",
"react/no-this-in-sfc": "error",
"react/prefer-stateless-function": "error",
"react/jsx-filename-extension": ["error", { "extensions": [".tsx"] }],
"react/jsx-no-bind": "error",
"react/jsx-no-literals": "warn",
"react/jsx-pascal-case": "error"
}
}
22 changes: 21 additions & 1 deletion .vscode/settings.json
Expand Up @@ -4,5 +4,25 @@
"files.insertFinalNewline": true,
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.formatOnSave": true
"editor.formatOnSave": true,
"eslint.run": "onSave",
"eslint.autoFixOnSave": false,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
}
}
64 changes: 31 additions & 33 deletions src/actions/auth.ts
@@ -1,5 +1,5 @@
import req from "../axios";
import { AxiosResponse, AxiosError } from "axios";
import { AxiosResponse } from "axios";
import { Dispatch } from "redux";

import Actions from "./list";
Expand All @@ -10,44 +10,42 @@ const tokenHeader = "X-Auth-Token";
/**
* Redux action creator. Performs an HTTP request, if it succeeds, copies
* the token from the response.
* @param username User name
* @param password Password in plain text
* @param user User name
* @param pass Password in plain text
*/
export const login = (username: string, password: string) =>
function(dispatch: Dispatch): void {
req.post("/login", {
name: username,
password: password,
}).then(
(res: AxiosResponse) => {
setToken(res.data.token);
dispatch({
type: Actions.LoginSuccess,
username: username,
token: res.data.token,
} as AuthAction);
},
(err: AxiosError) => {
dispatch({
type: Actions.LoginFailed,
} as AuthAction);
}
);
};
export const login = (user: string, pass: string) => (dispatch: Dispatch) => {
req.post("/login", {
name: user,
password: pass,
}).then(
(res: AxiosResponse) => {
setToken(res.data.token);
dispatch({
type: Actions.LoginSuccess,
username: user,
token: res.data.token,
} as AuthAction);
},
() => {
dispatch({
type: Actions.LoginFailed,
} as AuthAction);
}
);
};

/**
* Redux action creator. Performs an HTTP request, if it succeeds, clears
* the token from the cache.
*/
export const logout = () =>
function(dispatch: Dispatch): void {
req.post("/logout", {}).then(() => {
resetToken();
dispatch({
type: Actions.LoggedOut,
} as AuthAction);
});
};
export const logout = () => (dispatch: Dispatch) => {
req.post("/logout", {}).then(() => {
resetToken();
dispatch({
type: Actions.LoggedOut,
} as AuthAction);
});
};

/**
* Sets an auth token in the app's Axios instance to be used in every request
Expand Down

0 comments on commit fbc2ae4

Please sign in to comment.