Skip to content

Commit

Permalink
Enable ESLint Job (#1190)
Browse files Browse the repository at this point in the history
* Enable ESLint Job

* Use packages parameter

* Run as script

* Update lockfile

* Update PNP

* import fs

* eslint fixes

* Fixes
  • Loading branch information
timmo001 authored Jun 16, 2020
1 parent c9c5b12 commit 85f83d4
Show file tree
Hide file tree
Showing 47 changed files with 111 additions and 187 deletions.
4 changes: 1 addition & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand Down
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"arcanis.vscode-zipfs"
]
}
20 changes: 0 additions & 20 deletions .vscode/pnpify/eslint/bin/eslint.js

This file was deleted.

6 changes: 0 additions & 6 deletions .vscode/pnpify/eslint/package.json

This file was deleted.

20 changes: 0 additions & 20 deletions .vscode/pnpify/prettier/index.js

This file was deleted.

6 changes: 0 additions & 6 deletions .vscode/pnpify/prettier/package.json

This file was deleted.

20 changes: 0 additions & 20 deletions .vscode/pnpify/typescript/bin/tsc

This file was deleted.

20 changes: 0 additions & 20 deletions .vscode/pnpify/typescript/bin/tsserver

This file was deleted.

6 changes: 0 additions & 6 deletions .vscode/pnpify/typescript/package.json

This file was deleted.

6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"prettier.prettierPath": ".vscode/pnpify/prettier/index.js",
"typescript.tsdk": ".vscode/pnpify/typescript/lib",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"eslint.nodePath": ".vscode/pnpify"
"eslint.nodePath": ".yarn/sdks"
}
2 changes: 1 addition & 1 deletion azure-pipelines-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ stages:
- stage: 'Lint'
dependsOn: []
jobs:
# - template: azure-ci/lint/eslint.yml@organization
- template: azure-ci/lint/eslint.yml@organization
- template: azure-ci/lint/hadolint.yml@organization
- template: azure-ci/lint/jsonlint.yml@organization
- template: azure-ci/lint/markdownlint.yml@organization
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ stages:
- stage: 'Lint'
dependsOn: []
jobs:
# - template: azure-ci/lint/eslint.yml@organization
- template: azure-ci/lint/eslint.yml@organization
- template: azure-ci/lint/hadolint.yml@organization
- template: azure-ci/lint/jsonlint.yml@organization
- template: azure-ci/lint/markdownlint.yml@organization
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ stages:
- stage: 'Lint'
dependsOn: []
jobs:
# - template: azure-ci/lint/eslint.yml@organization
- template: azure-ci/lint/eslint.yml@organization
- template: azure-ci/lint/hadolint.yml@organization
- template: azure-ci/lint/jsonlint.yml@organization
- template: azure-ci/lint/markdownlint.yml@organization
Expand Down
2 changes: 1 addition & 1 deletion backend/src/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Application } from './declarations';

declare module './declarations' {
interface ServiceTypes {
authentication: AuthenticationService & ServiceAddons<any>;
authentication: AuthenticationService & ServiceAddons<unknown>;
}
}

Expand Down
5 changes: 3 additions & 2 deletions backend/src/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ export default function (app: Application): void {
return;
}

app.on('connection', (connection: any): void => {
app.on('connection', (connection: unknown): void => {
// On a new real-time connection, add it to the anonymous channel
app.channel('anonymous').join(connection);
});

app.on('login', (authResult: any, { connection }: any) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
app.on('login', (_authResult: any, { connection }: any) => {
// connection can be undefined if there is no
// real-time connection, e.g. when logging in via REST
if (connection) {
Expand Down
10 changes: 8 additions & 2 deletions backend/src/hooks/populate-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
// For more information on hooks see: http://docs.feathersjs.com/api/hooks.html
import { Hook, HookContext } from '@feathersjs/feathers';

interface Configuration {
user: string;
userId: string;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export default (_options = {}): Hook => {
return async (context: HookContext): Promise<HookContext> => {
// Get `app`, `method`, `params` and `result` from the hook context
Expand All @@ -18,14 +24,14 @@ export default (_options = {}): Hook => {
// Asynchronously get user object from each message's `userId`
// and add it to the message
await Promise.all(
config.map(async (config: any) => {
config.map(async (config: Configuration) => {
// Also pass the original `params` to the service call
// so that it has the same information available (e.g. who is requesting it)
config.user = await app.service('users').get(config.userId, params);
})
);

config = config.filter((config: any) => config.userId === userId);
config = config.filter((config: Configuration) => config.userId === userId);

if (method === 'find') result.data = config;
else result = result.userId === userId ? result : null;
Expand Down
1 change: 1 addition & 0 deletions backend/src/hooks/process-config-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// For more information on hooks see: http://docs.feathersjs.com/api/hooks.html
import { Hook, HookContext } from '@feathersjs/feathers';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export default (_options = {}): Hook => {
return async (context: HookContext) => {
const { data } = context;
Expand Down
4 changes: 3 additions & 1 deletion backend/src/hooks/process-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Use this hook to manipulate incoming or outgoing data.
// For more information on hooks see: http://docs.feathersjs.com/api/hooks.html
import { Hook, HookContext } from '@feathersjs/feathers';
import fs from 'fs';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export default (_options = {}): Hook => {
return async (context: HookContext): Promise<HookContext> => {
const { data } = context;
Expand All @@ -10,7 +12,7 @@ export default (_options = {}): Hook => {

if (createNew) {
config = JSON.parse(
require('fs').readFileSync('config/config.default.json')
String(fs.readFileSync('config/config.default.json'))
);
// Throw an error if there isn't any default config
if (!config)
Expand Down
1 change: 1 addition & 0 deletions backend/src/hooks/process-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// For more information on hooks see: http://docs.feathersjs.com/api/hooks.html
import { Hook, HookContext } from '@feathersjs/feathers';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export default (_options = {}): Hook => {
return async (context: HookContext): Promise<HookContext> => {
const { app, data, params } = context;
Expand Down
3 changes: 2 additions & 1 deletion backend/src/middleware/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Application } from '../declarations';
// Don't remove this comment. It's needed to format import lines nicely.

export default function (app: Application) {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-empty-function
export default function (_app: Application) {}
1 change: 1 addition & 0 deletions backend/src/models/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import NeDB from 'nedb';
import path from 'path';
import { Application } from '../declarations';

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default function (app: Application) {
const dbPath = app.get('nedb');
const Model = new NeDB({
Expand Down
1 change: 1 addition & 0 deletions backend/src/models/users.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import NeDB from 'nedb';
import path from 'path';
import { Application } from '../declarations';

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default function (app: Application) {
const dbPath = app.get('nedb');
const Model = new NeDB({
Expand Down
1 change: 1 addition & 0 deletions backend/src/services/config/config.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Service, NedbServiceOptions } from 'feathers-nedb';
import { Application } from '../../declarations';

export class Config extends Service {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
constructor(options: Partial<NedbServiceOptions>, _app: Application) {
super(options);
}
Expand Down
4 changes: 2 additions & 2 deletions backend/src/services/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import hooks from './config.hooks';
// Add this service to the service type index
declare module '../../declarations' {
interface ServiceTypes {
config: Config & ServiceAddons<any>;
config: Config & ServiceAddons<unknown>;
}
}

export default function (app: Application) {
export default function (app: Application): void {
const Model = createModel(app);
const paginate = app.get('paginate');

Expand Down
5 changes: 5 additions & 0 deletions backend/src/services/controller/controller.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ export class Controller implements ServiceMethods<Data> {
this.app = app;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async find(_params?: Params): Promise<Data[] | Paginated<Data>> {
return [];
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async get(id: Id, _params?: Params): Promise<Data> {
return {
id,
Expand All @@ -41,14 +43,17 @@ export class Controller implements ServiceMethods<Data> {
return data;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async update(_id: NullableId, data: Data, _params?: Params): Promise<Data> {
return data;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async patch(_id: NullableId, data: Data, _params?: Params): Promise<Data> {
return data;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async remove(id: NullableId, _params?: Params): Promise<Data> {
return { id };
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/services/controller/controller.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import hooks from './controller.hooks';
// Add this service to the service type index
declare module '../../declarations' {
interface ServiceTypes {
controller: Controller & ServiceAddons<any>;
controller: Controller & ServiceAddons<unknown>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/services/users/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import hooks from './users.hooks';
// Add this service to the service type index
declare module '../../declarations' {
interface ServiceTypes {
users: Users & ServiceAddons<any>;
users: Users & ServiceAddons<unknown>;
}
}

Expand Down
9 changes: 1 addition & 8 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "CI=true react-scripts test --forceExit --detectOpenHandles --coverage --coverageDirectory=output/coverage/jest --reporters=default --reporters=jest-junit",
"eject": "react-scripts eject",
"eslint": "eslint -c .eslintrc.json --color src"
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
Expand Down Expand Up @@ -81,13 +80,7 @@
"@types/socket.io": "2.1.8",
"@types/socket.io-client": "1.4.33",
"@types/superagent": "4.1.7",
"@typescript-eslint/eslint-plugin": "3.2.0",
"@typescript-eslint/parser": "3.2.0",
"@yarnpkg/pnpify": "2.0.0-rc.25",
"eslint": "7.2.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-react": "7.20.0",
"jest-junit": "10.0.0",
"prettier": "2.0.5",
"typescript": "3.9.5"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/Configuration/EditCard/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface BaseProps {
) => (event: React.ChangeEvent<HTMLInputElement>) => void;
handleSwitchChange?: (
name: string
) => (_event: React.ChangeEvent<{}>, checked: boolean) => void;
) => (_event: React.ChangeEvent<unknown>, checked: boolean) => void;
handleSelectChange?: (
event: React.ChangeEvent<{ name?: string; value: unknown }>
) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function EditCard(props: EditCardProps): ReactElement {
};

const handleSwitchChange = (name: string) => (
_event: React.ChangeEvent<{}>,
_event: React.ChangeEvent<unknown>,
checked: boolean
): void => {
setCard({ ...card, [name]: checked });
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/Configuration/EditCard/News.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function News(props: BaseProps): ReactElement {
const [error, setError] = useState<string>();

function handleChange(
_event: React.ChangeEvent<{}>,
_event: React.ChangeEvent<unknown>,
newValue: Option | null
): void {
setSource(newValue);
Expand Down
Loading

0 comments on commit 85f83d4

Please sign in to comment.