lint: replace tslint with eslint and fix new warnings and errors.

master
Tom Hacohen 5 years ago
parent f29edf1563
commit 11dd883f5f

@ -0,0 +1 @@
EXTEND_ESLINT=true

@ -0,0 +1,98 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"settings": {
"react": {
"version": "detect",
},
},
"plugins": [
"@typescript-eslint",
],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/member-delimiter-style": ["error", {
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "comma",
"requireLast": false
}
}],
"@typescript-eslint/no-unused-vars": ["warn", {
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": true,
"argsIgnorePattern": "^_",
}],
"react/display-name": "off",
"react/no-unescaped-entities": "off",
"react/jsx-tag-spacing": ["error", {
"closingSlash": "never",
"beforeSelfClosing": "always",
"afterOpening": "never",
"beforeClosing": "never"
}],
"react/jsx-boolean-value": ["error", "never"],
"react/jsx-curly-spacing": ["error", "never"],
"react/jsx-key": ["error", { "checkFragmentShorthand": true }],
"quotes": "off",
"@typescript-eslint/quotes": ["error", "single", { "allowTemplateLiterals": true }],
"semi": ["error", "always", { "omitLastInOneLineBlock": true }],
"camelcase": ["error"],
"comma-dangle": ["error", {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}],
"eqeqeq": ["error", "smart"],
"indent": ["error", 2, {
"SwitchCase": 1,
}],
"no-multi-spaces": "error",
"object-curly-spacing": ["error", "always"],
"arrow-parens": "error",
"arrow-spacing": "error",
"key-spacing": "error",
"keyword-spacing": "error",
"func-call-spacing": "off",
"@typescript-eslint/func-call-spacing": ["error"],
"space-before-function-paren": ["error", {
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}],
"space-in-parens": ["error", "never"],
"space-before-blocks": "error",
"curly": ["error", "all"],
"space-infix-ops": "error",
"consistent-return": "error",
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"jsx-quotes": ["error"],
}
};

2
.gitignore vendored

@ -21,5 +21,3 @@ Session.vim
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/.env

@ -51,8 +51,6 @@
"@types/sjcl": "^1.0.28",
"@types/urijs": "^1.15.38",
"@types/uuid": "^3.4.3",
"tslint": "^5.12.1",
"tslint-react": "^3.6.0",
"typescript": "^3.3.3"
},
"browserslist": [

@ -97,11 +97,11 @@ export const routeResolver = new RouteResolver({
const AppBarWitHistory = withRouter(
class extends React.PureComponent {
public props: {
title: string,
toggleDrawerIcon: any,
title: string;
toggleDrawerIcon: any;
history?: History;
staticContext?: any;
iconElementRight: any,
iconElementRight: any;
};
constructor(props: any) {
@ -159,7 +159,7 @@ const IconRefreshWithSpin = withSpin(NavigationRefresh);
class App extends React.PureComponent {
public state: {
drawerOpen: boolean,
drawerOpen: boolean;
};
public props: {

@ -51,8 +51,8 @@ const JournalTaskList = journalView(TaskList, Task);
class Journal extends React.Component<PropsTypeInner> {
public state: {
tab: number,
importDialogOpen: boolean,
tab: number;
importDialogOpen: boolean;
};
constructor(props: PropsTypeInner) {

@ -14,9 +14,9 @@ function objValues(obj: any) {
export function journalView(JournalList: any, JournalItem: any) {
return withRouter(class extends React.PureComponent {
public props: {
journal: EteSync.Journal,
entries: {[key: string]: any},
history?: History,
journal: EteSync.Journal;
entries: {[key: string]: any};
history?: History;
};
constructor(props: any) {

@ -101,12 +101,12 @@ const ItemChangeLog = React.memo((props: any) => {
});
type CollectionRoutesPropsType = RouteComponentProps<{}> & {
syncInfo: SyncInfo,
routePrefix: string,
collections: EteSync.CollectionInfo[],
componentEdit: any,
componentView: any,
items: {[key: string]: PimType},
syncInfo: SyncInfo;
routePrefix: string;
collections: EteSync.CollectionInfo[];
componentEdit: any;
componentView: any;
items: {[key: string]: PimType};
onItemSave: (item: PimType, journalUid: string, originalContact?: PimType) => void;
onItemDelete: (item: PimType, journalUid: string) => void;
onItemCancel: () => void;

@ -169,7 +169,7 @@ class SyncGate extends React.PureComponent<PropsTypeInner> {
if (errors.length > 0) {
return (
<ul>
{errors.map((error) => (<li>{error.journal}: {error.error.toString()}</li>))}
{errors.map((error, idx) => (<li key={idx}>{error.journal}: {error.error.toString()}</li>))}
</ul>
);
}
@ -193,13 +193,13 @@ class SyncGate extends React.PureComponent<PropsTypeInner> {
<Route
path={routeResolver.getRoute('home')}
exact
render={({match}) => (
render={() => (
<Redirect to={routeResolver.getRoute('pim')} />
)}
/>
<Route
path={routeResolver.getRoute('pim')}
render={({match, history}) => (
render={({ history }) => (
<>
<AppBarOverride title="EteSync" />
<PimRouter
@ -238,7 +238,7 @@ class SyncGate extends React.PureComponent<PropsTypeInner> {
}
}
const mapStateToProps = (state: StoreState, props: PropsType) => {
const mapStateToProps = (state: StoreState, _props: PropsType) => {
return {
settings: state.settings,
journals: state.cache.journals,

@ -497,7 +497,7 @@ export class EntryManager extends BaseManager {
super(credentials, apiBase, ['journals', journalId, 'entries', '']);
}
public list(lastUid: string | null, limit: number = 0): Promise<Entry[]> {
public list(lastUid: string | null, limit = 0): Promise<Entry[]> {
let apiBase = this.apiBase.clone();
apiBase = apiBase.search({
last: (lastUid !== null) ? lastUid : undefined,

@ -16,7 +16,7 @@ import { IconButton } from '@material-ui/core';
class Contact extends React.PureComponent {
public props: {
item?: ContactType,
item?: ContactType;
};
public render() {

@ -122,7 +122,7 @@ interface PropsType {
class ContactEdit extends React.PureComponent<PropsType> {
public state: {
uid: string,
uid: string;
fn: string;
phone: ValueType[];
email: ValueType[];

@ -8,7 +8,7 @@ interface FormErrors {
class EncryptionLoginForm extends React.PureComponent {
public state: {
errors: FormErrors,
errors: FormErrors;
encryptionPassword: string;
};

@ -6,17 +6,21 @@ import { resetKey } from '../store/actions';
import { EncryptionPasswordError, IntegrityError } from '../api/EteSync';
import PrettyError from '../widgets/PrettyError';
class ErrorBoundary extends React.Component {
interface PropsType {
children: React.ReactNode | React.ReactNode[];
}
class ErrorBoundary extends React.Component<PropsType> {
public state: {
error?: Error;
};
constructor(props: any) {
constructor(props: PropsType) {
super(props);
this.state = { };
}
public componentDidCatch(error: Error, info: any) {
public componentDidCatch(error: Error, _info: any) {
if (error instanceof EncryptionPasswordError) {
store.dispatch(resetKey());
} else if (error instanceof IntegrityError) {

@ -8,7 +8,7 @@ import { EventType } from '../pim-types';
class Event extends React.PureComponent {
public props: {
item?: EventType,
item?: EventType;
};
public render() {

@ -42,7 +42,7 @@ interface PropsType {
class EventEdit extends React.PureComponent<PropsType> {
public state: {
uid: string,
uid: string;
title: string;
allDay: boolean;
start?: Date;

@ -27,9 +27,9 @@ class JournalEntries extends React.PureComponent {
};
public props: {
journal: EteSync.Journal,
entries: Immutable.List<EteSync.SyncEntry>,
uid?: string,
journal: EteSync.Journal;
entries: Immutable.List<EteSync.SyncEntry>;
uid?: string;
};
constructor(props: any) {

@ -12,8 +12,8 @@ import AddressBook from '../components/AddressBook';
class SearchableAddressBook extends React.PureComponent {
public props: {
entries: ContactType[],
onItemClick: (contact: ContactType) => void,
entries: ContactType[];
onItemClick: (contact: ContactType) => void;
};
public state: {

@ -8,7 +8,7 @@ import { TaskType } from '../pim-types';
class Task extends React.PureComponent {
public props: {
item?: TaskType,
item?: TaskType;
};
public render() {

@ -42,7 +42,7 @@ interface PropsType {
class TaskEdit extends React.PureComponent<PropsType> {
public state: {
uid: string,
uid: string;
title: string;
status: TaskStatusType;
allDay: boolean;

@ -41,8 +41,8 @@ const sortSelector = createSelector(
class TaskList extends React.PureComponent {
public props: {
entries: TaskType[],
onItemClick: (contact: TaskType) => void,
entries: TaskType[];
onItemClick: (contact: TaskType) => void;
};
public render() {

@ -53,7 +53,7 @@ export type UserInfoType = FetchType<UserInfoData>;
export type UserInfoTypeImmutable = Record<UserInfoType>;
function fetchTypeIdentityReducer(
state: Record<FetchType<any>> = fetchTypeRecord<any>()(), action: any, extend: boolean = false) {
state: Record<FetchType<any>> = fetchTypeRecord<any>()(), action: any, extend = false) {
if (action.error) {
return state.set('error', action.payload);
} else {
@ -97,7 +97,7 @@ export const encryptionKeyReducer = handleActions(
export const credentials = handleActions(
{
[actions.fetchCredentials.toString()]: (
state: CredentialsTypeRemote, action: any, extend: boolean = false) => {
state: CredentialsTypeRemote, action: any, extend = false) => {
if (action.error) {
return {
value: null,
@ -229,7 +229,7 @@ export const userInfo = handleAction(
actions.fetchUserInfo,
actions.createUserInfo
),
(state: Record<FetchType<any>> = fetchTypeRecord<any>()(), action: any, extend: boolean = false) => {
(state: Record<FetchType<any>> = fetchTypeRecord<any>()(), action: any, extend = false) => {
if (action.error) {
return state.set('error', action.payload);
} else {

@ -1,42 +0,0 @@
{
"extends": ["tslint:recommended", "tslint-react"],
"rules": {
"no-console": [true, "error"],
"interface-name": [true, "never-prefix"],
"ordered-imports": false,
"jsx-boolean-value": [true, "never"],
"jsx-curly-spacing": [true, "never"],
"jsx-no-bind": [true, "allowArrowFunctions"],
"jsx-no-lambda": [false],
"jsx-no-multiline-js": false,
"jsx-space-before-trailing-slash": true,
"jsx-key": true,
"max-classes-per-file": [false, 0],
"max-line-length": false,
"no-consecutive-blank-lines": false,
"no-conditional-assignment": false,
"object-literal-sort-keys": false,
"quotemark": [true, "single", "jsx-double", "avoid-escape", "avoid-template"],
"semicolon": [true, "always", "ignore-bound-class-methods"],
"variable-name": [true, "ban-keywords", "check-format", "allow-pascal-case", "allow-leading-underscore"],
"trailing-comma": [
true,
{
"multiline": {
"objects": "always",
"arrays": "always",
"functions": "never",
"typeLiterals": "ignore"
},
"esSpecCompliant": true
}
],
"whitespace": [true,"check-branch", "check-decl", "check-operator", "check-module", "check-separator", "check-rest-spread", "check-type", "check-typecast", "check-type-operator", "check-preblock"]
},
"linterOptions": {
"exclude": [
"config/**/*.js",
"node_modules/**/*.ts"
]
}
}

@ -2461,11 +2461,6 @@ buffer@^4.3.0:
ieee754 "^1.1.4"
isarray "^1.0.0"
builtin-modules@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=
builtin-status-codes@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8"
@ -2601,7 +2596,7 @@ caseless@~0.12.0:
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=
chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2:
chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
@ -2824,7 +2819,7 @@ commander@^2.11.0, commander@^2.20.0, commander@~2.20.3:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
commander@^2.12.1, commander@~2.19.0:
commander@~2.19.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==
@ -3531,11 +3526,6 @@ diff-sequences@^24.9.0:
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5"
integrity sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==
diff@^3.2.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
diffie-hellman@^5.0.0:
version "5.0.3"
resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875"
@ -6010,7 +6000,7 @@ js-tokens@^3.0.2:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=
js-yaml@^3.13.1, js-yaml@^3.7.0:
js-yaml@^3.13.1:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
@ -10182,48 +10172,11 @@ ts-pnp@1.1.4, ts-pnp@^1.1.2:
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.1.4.tgz#ae27126960ebaefb874c6d7fa4729729ab200d90"
integrity sha512-1J/vefLC+BWSo+qe8OnJQfWTYRS6ingxjwqmHMqaMxXMj7kFtKLgAaYW3JeX3mktjgUL+etlU8/B4VUAUI9QGw==
tslib@^1.8.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
tslib@^1.8.1, tslib@^1.9.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
tslint-react@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/tslint-react/-/tslint-react-3.6.0.tgz#7f462c95c4a0afaae82507f06517ff02942196a1"
integrity sha512-AIv1QcsSnj7e9pFir6cJ6vIncTqxfqeFF3Lzh8SuuBljueYzEAtByuB6zMaD27BL0xhMEqsZ9s5eHuCONydjBw==
dependencies:
tsutils "^2.13.1"
tslint@^5.12.1:
version "5.12.1"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.12.1.tgz#8cec9d454cf8a1de9b0a26d7bdbad6de362e52c1"
integrity sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw==
dependencies:
babel-code-frame "^6.22.0"
builtin-modules "^1.1.1"
chalk "^2.3.0"
commander "^2.12.1"
diff "^3.2.0"
glob "^7.1.1"
js-yaml "^3.7.0"
minimatch "^3.0.4"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.8.0"
tsutils "^2.27.2"
tsutils@^2.13.1, tsutils@^2.27.2:
version "2.29.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99"
integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==
dependencies:
tslib "^1.8.1"
tsutils@^3.17.1:
version "3.17.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"

Loading…
Cancel
Save