Skip to content

Commit

Permalink
fix(*): linter rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Komarov authored and Alexander Komarov committed Dec 1, 2023
1 parent 848dfe5 commit a0ce260
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 55 deletions.
11 changes: 7 additions & 4 deletions packages/arui-scripts-modules/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ module.exports = {
extends: ['custom/common'],
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'./tsconfig.eslint.json',
],
project: ['./tsconfig.eslint.json'],
},
overrides: [
{
files: ['**/__tests__/**/*.{ts,tsx}'],
rules: {
'import/no-extraneous-dependencies': 'off',
},
}
},
],
rules: {
'no-underscore-dangle': 'off',
'@typescript-eslint/naming-convention': 'off',
'no-console': 'off',
},
};
2 changes: 0 additions & 2 deletions packages/arui-scripts-modules/global-definitions.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable @typescript-eslint/naming-convention,no-underscore-dangle */
declare const __webpack_share_scopes__: {
default: unknown;
};
/* eslint-enable @typescript-eslint/naming-convention,no-underscore-dangle */
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// TODO: remove eslint-disable
/* eslint-disable no-underscore-dangle */
import { fetchAppManifest } from './utils/fetch-app-manifest';
import { urlSegmentWithoutEndSlash } from './utils/normalize-url-segment';
import { ModuleResourcesGetter } from './create-module-loader';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export function useModuleFactory<
return;
}
setLoadingState('rejected');
// eslint-disable-next-line no-console
console.error(error);
}
}
Expand All @@ -112,6 +111,7 @@ export function useModuleFactory<
abortController.abort();
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [loader]);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export function useModuleLoader<ModuleExportType, GetResourcesParams>({
return;
}
setLoadingState('rejected');
// eslint-disable-next-line no-console
console.error(error);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export function useModuleMounter<LoaderParams, RunParams, ServerState extends Ba
return;
}
setLoadingState('rejected');
// eslint-disable-next-line no-console
console.error(error);

return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-underscore-dangle */
import { ModuleFederationContainer } from '../../types';
import { getCompatModule, getModule } from '../get-module';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export async function getModule<ModuleType>(containerId: string, moduleId: strin
}

// webpack любит двойные подчеркивания для внутренних функций
// eslint-disable-next-line @typescript-eslint/naming-convention
await container.init(__webpack_share_scopes__.default);
const factory = await container.get<ModuleType>(moduleId);

Expand Down
15 changes: 9 additions & 6 deletions packages/arui-scripts-server/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ module.exports = {
root: true,
extends: ['custom/common'],
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'./tsconfig.eslint.json'
],
},
};
tsconfigRootDir: __dirname,
project: ['./tsconfig.eslint.json'],
},
rules: {
'no-underscore-dangle': 'off',
'@typescript-eslint/naming-convention': 'off',
'no-console': 'off',
},
};
4 changes: 2 additions & 2 deletions packages/arui-scripts-server/src/hapi-20.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO: remove eslint-disable-next-line
import type { Plugin, Request } from 'hapi20';

import { createGetModulesMethod, ModulesConfig } from './modules';
Expand All @@ -19,7 +18,6 @@ export function createGetModulesHapi20Plugin(
options: {
...routeParams,
},
// eslint-disable-next-line consistent-return
handler: async (request, h) => {
try {
return await modulesMethodSettings.handler(request.payload as any, request);

Check warning on line 23 in packages/arui-scripts-server/src/hapi-20.ts

View workflow job for this annotation

GitHub Actions / build (14.x)

Unexpected any. Specify a different type

Check warning on line 23 in packages/arui-scripts-server/src/hapi-20.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected any. Specify a different type

Check warning on line 23 in packages/arui-scripts-server/src/hapi-20.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected any. Specify a different type
Expand All @@ -28,6 +26,8 @@ export function createGetModulesHapi20Plugin(
error: e.message,
status: 500,
}).code(500);

return undefined;
}
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO: remove eslint-disable-next-line
import type { GetResourcesRequest, ModuleResources } from '@alfalab/scripts-modules';

import { getAppManifest, readAssetsManifest } from '../read-assets-manifest';
Expand Down Expand Up @@ -51,7 +50,6 @@ export function createGetModulesMethod<FrameworkParams extends unknown[] = []>(
...moduleRunParams,
hostAppId: getResourcesRequest.hostAppId,
},
// eslint-disable-next-line no-underscore-dangle
appName: appManifest.__metadata__.name,
};
},
Expand Down
5 changes: 5 additions & 0 deletions packages/example/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ module.exports = {
tsconfigRootDir: __dirname,
project: ['./tsconfig.eslint.json', './validate-build/tsconfig.json'],
},
rules: {
'import/no-extraneous-dependencies': 'off',
'no-console': 'off',
'no-restricted-syntax': 'off',
},
};
30 changes: 14 additions & 16 deletions packages/example/arui-scripts.overrides.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
// TODO: remove eslint-disable-next-line
import path from 'path';

import { OverrideFile } from 'arui-scripts';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import path from 'node:path';
// eslint-disable-next-line import/no-extraneous-dependencies
import {RuleSetRule} from 'webpack';

const overrides: OverrideFile = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
webpackClient: (config, appConfig, { createSingleClientWebpackConfig, findLoader }) => {
const workerConfig = createSingleClientWebpackConfig(
{ worker: './src/worker.ts' },
'worker',
);

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
workerConfig.output.filename = 'worker.js';
if (workerConfig.output) {
workerConfig.output.filename = 'worker.js';
}

const rootConfigList = Array.isArray(config) ? config : [config];

// Делаем стабильные имена классов css модулей для тестирования
// eslint-disable-next-line no-restricted-syntax
for (const rootConfig of rootConfigList) {
const cssModulesLoader = findLoader(rootConfig, '/\\.module\\.css$/');

Expand Down Expand Up @@ -53,10 +46,15 @@ const overrides: OverrideFile = {
const allConfigs = Array.isArray(config) ? config : [config];

return allConfigs.map((config) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line no-param-reassign
config.optimization.minimize = false;
if (config.optimization) {
return {
...config,
optimization: {
...config.optimization,
minimize: false,
}
}
}

return config;
});
Expand Down
6 changes: 2 additions & 4 deletions packages/example/src/client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO: remove eslint-disable-next-line
import React from 'react';
import ReactDOM from 'react-dom';

Expand All @@ -9,9 +8,8 @@ const targetElement = document.getElementById('app');
if (process.env.NODE_ENV !== 'production' && module.hot) {
ReactDOM.render(<App />, targetElement);

module.hot.accept('./components/app', () => {
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
const NextAppAssignments = require('./components/app').App;
module.hot.accept('./components/app', async () => {
const NextAppAssignments = await import('./components/app').then(({ App }) => App);

ReactDOM.render(<NextAppAssignments />, targetElement);
});
Expand Down
9 changes: 3 additions & 6 deletions packages/example/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// TODO: remove eslint-disable
/* eslint-disable no-param-reassign */
/* eslint-disable operator-assignment */
export enum YesNoEnum {
Yes = 'Yes',
No = 'No',
}

export function isSmaller(a: number, b: number) {
a = a * 10_000;
b = b * 10_000;
const calculatedA = a * 10_000;
const calculatedB = b * 10_000;

return a > b ? YesNoEnum.Yes : YesNoEnum.No;
return calculatedA > calculatedB ? YesNoEnum.Yes : YesNoEnum.No;
}

type OptionalChainingTest = {
Expand Down
8 changes: 2 additions & 6 deletions packages/example/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// TODO: remove eslint-disable
/* eslint-disable no-console */
/* eslint-disable no-restricted-globals */
// This code executes in its own worker or thread
self.addEventListener('install', () => {
globalThis.addEventListener('install', () => {
console.log('Service worker installed');
});
self.addEventListener('activate', () => {
globalThis.addEventListener('activate', () => {
console.log('Service worker activated');
});

0 comments on commit a0ce260

Please sign in to comment.