Skip to content

Commit

Permalink
Tools: Extended eslint rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
bre1470 committed Aug 7, 2024
1 parent 7b5febc commit 7bc9204
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 34 deletions.
59 changes: 58 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,64 @@
"Highcharts": false
},
"rules": {
"@typescript-eslint/restrict-plus-operands": 0
"camelcase": [2, {"properties": "always"}],
"comma-dangle": [2, "never"],
"dot-location": [2, "property"],
"lines-around-comment": 0,
"max-len": [2, {"code": 100, "comments": 80}],
"newline-after-var": 0,
"no-alert": 2,
"no-console": 2,
"no-debugger": 2,
"no-else-return": 2,
"no-nested-ternary": 0,
"no-unmodified-loop-condition": 0,
"no-unused-vars": 1,
"object-curly-spacing": [2, "always"],
"operator-linebreak": [2, "after"],
"quotes": [2, "single"],
"require-unicode-regexp": 1,
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}], // JSLint style
"strict": 0,
"@typescript-eslint/restrict-plus-operands": 0,
"jsdoc/check-alignment": 1,
"jsdoc/check-param-names": 1,
"jsdoc/check-tag-names": 1,
"jsdoc/check-types": 0,
"jsdoc/newline-after-description": 0,
"jsdoc/require-jsdoc": 0,
"jsdoc/require-param": 1,
"jsdoc/require-returns": 0,
"node/shebang": 0,
"node/no-unpublished-require": 0
},
"settings": {
"jsdoc": {
"preferredTypes": {
"array": "Array",
"function": "Function",
"object": "Object",
"Boolean": "boolean",
"Number": "number",
"Object": "Object",
"String": "string"
},
"tagNamePreference": {
"augments": "augments",
"class": "class",
"constructor": "class",
"emits": "emits",
"extends": "extends",
"fires": "emits",
"returns": "return"
}
}
}
},
{
"files": ["test/unit-tests/runtime.ts"],
"rules": {
"no-console": 0
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/RNANews/RNANewsOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import type LocalizationOptions from '../Shared/LocalizationOptions';

import MorningstarOptions, { MorningstarConverterOptions, MorningstarSecurityOptions } from "../Shared/MorningstarOptions";
import MorningstarOptions, { MorningstarConverterOptions, MorningstarSecurityOptions } from '../Shared/MorningstarOptions';
import RNANewsJSON from './RNANewsJSON';


Expand Down
2 changes: 1 addition & 1 deletion src/RNANews/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* */


import RNANewsConnector from "./RNANewsConnector";
import RNANewsConnector from './RNANewsConnector';


/* *
Expand Down
8 changes: 4 additions & 4 deletions src/Shared/MorningstarAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class MorningstarAPI {
* */


public constructor (
public constructor(
options: MorningstarAPIOptions = {}
) {

Expand All @@ -66,7 +66,7 @@ export class MorningstarAPI {
this.requestDelay = 0;
this.version = (
options.version ??
parseInt((this.baseURL.pathname.match(/\/v(\d+)(?:\/|$)/) || [])[ 1 ], 10)
parseInt((this.baseURL.pathname.match(/\/v(\d+)(?:\/|$)/u) || [])[ 1 ], 10)
);
this.version = (this.version > 0 ? this.version : 1);

Expand Down Expand Up @@ -107,14 +107,14 @@ export class MorningstarAPI {
* */


public delay (
public delay(
milliseconds: number
): Promise<void> {
return new Promise(resolve => window.setTimeout(resolve, milliseconds));
}


public async fetch (
public async fetch(
url: MorningstarURL,
requestInit: RequestInit = {}
): Promise<Response> {
Expand Down
4 changes: 2 additions & 2 deletions src/Shared/MorningstarAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
* */


import type { MorningstarAccessOptions } from "./MorningstarOptions";
import type { MorningstarAccessOptions } from './MorningstarOptions';

import MorningstarRegion from "./MorningstarRegion";
import MorningstarRegion from './MorningstarRegion';


/* *
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/MorningstarConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export abstract class MorningstarConnector extends External.DataConnector {
* */


public constructor (
public constructor(
options: MorningstarOptions = {}
) {
super(options);
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/MorningstarConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export abstract class MorningstarConverter extends External.DataConverter {
* */


public constructor (
public constructor(
options: MorningstarConverterOptions = {}
) {
super(options);
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/MorningstarError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class MorningstarError extends Error {
* */


public constructor (
public constructor(
request: RequestInit,
response: Response
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/MorningstarPostman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export namespace MorningstarPostman {
const apiOptions: MorningstarAPIOptions = {};

const password = postmanEnvironment.getValueOf('Morningstar as a Service Password');
const url = postmanEnvironment.getValueOf(/^Morningstar as a Service \(/);
const url = postmanEnvironment.getValueOf(/^Morningstar as a Service \(/u);
const username = postmanEnvironment.getValueOf('Morningstar as a Service Username');

if (password && username) {
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/MorningstarRegion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export namespace MorningstarRegion {


export function detect(): Name {
const country = window.navigator.language.toUpperCase().match(/-(\w\w)/);
const country = window.navigator.language.toUpperCase().match(/-(\w\w)/u);

if (country) {
if (countriesAmericas.includes(country[1])) {
Expand Down
1 change: 0 additions & 1 deletion src/TimeSeries/Converters/DividendSeriesConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export class DividendSeriesConverter extends MorningstarConverter {
// Validate JSON

if (!TimeSeriesJSON.isTimeSeriesResponse(json)) {
console.log(json);
throw new Error('Invalid data');
}

Expand Down
2 changes: 1 addition & 1 deletion src/TimeSeries/TimeSeriesConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class TimeSeriesConnector extends MorningstarConnector {
* */


public constructor (
public constructor(
options: TimeSeriesOptions
) {
super(options);
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/Shared/MorningstarAPI.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Assert from 'node:assert/strict';
import * as MC from '../../../code/morningstar-connectors.src';

export async function api_access(
export async function apiAccess(
apiOptions: MC.Shared.MorningstarAPIOptions
) {
const api = new MC.Shared.MorningstarAPI(apiOptions);

Check failure on line 7 in test/unit-tests/Shared/MorningstarAPI.test.ts

View workflow job for this annotation

GitHub Actions / Test eslint style

Unsafe assignment of an error typed value

Check failure on line 7 in test/unit-tests/Shared/MorningstarAPI.test.ts

View workflow job for this annotation

GitHub Actions / Test eslint style

Unsafe construction of an any type value

Check failure on line 7 in test/unit-tests/Shared/MorningstarAPI.test.ts

View workflow job for this annotation

GitHub Actions / Test eslint style

Unsafe member access .Shared on an `error` typed value
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/TimeSeries/DividendConverter.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Assert from 'node:assert/strict';
import * as MorningstarConnectors from '../../../code/morningstar-connectors.src';

export async function rating_load(
export async function ratingLoad(
api: MorningstarConnectors.Shared.MorningstarAPIOptions
) {
const connector = new MorningstarConnectors.TimeSeriesConnector({

Check failure on line 7 in test/unit-tests/TimeSeries/DividendConverter.test.ts

View workflow job for this annotation

GitHub Actions / Test eslint style

Unsafe assignment of an error typed value

Check failure on line 7 in test/unit-tests/TimeSeries/DividendConverter.test.ts

View workflow job for this annotation

GitHub Actions / Test eslint style

Unsafe construction of an any type value

Check failure on line 7 in test/unit-tests/TimeSeries/DividendConverter.test.ts

View workflow job for this annotation

GitHub Actions / Test eslint style

Unsafe member access .TimeSeriesConnector on an `error` typed value
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async function runUnitTests() {
for (let testName of Object.keys(unitTests)) {

test = unitTests[testName];
testName = testName.replace('_', ' ');
testName = testName.replace(/[A-Z]+/u, ' $0').toLowerCase();

if (typeof test === 'function') {

Expand Down
30 changes: 15 additions & 15 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ const sharedConfiguration: Configuration = {
performance: {
hints: 'error',
maxAssetSize: 100000,
maxEntrypointSize: 100000,
maxEntrypointSize: 100000
},

resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
extensions: ['.tsx', '.ts', '.js']
}

};

Expand All @@ -86,19 +86,19 @@ const webpacks: Array<Configuration> = [
name: {
amd: `${amd}/morningstar-connectors`,
commonjs,
root: [root, 'MorningstarConnectors'],
root: [root, 'MorningstarConnectors']
},
type: 'umd',
umdNamedDefine: true,
umdNamedDefine: true
},
path: Path.resolve(projectFolder, targetFolder),
path: Path.resolve(projectFolder, targetFolder)
},

performance: {
hints: 'error',
maxAssetSize: 200000,
maxEntrypointSize: 200000,
},
maxEntrypointSize: 200000
}

},
// Morningstar RNA news
Expand All @@ -119,10 +119,10 @@ const webpacks: Array<Configuration> = [
root: [root, 'MorningstarConnectors', 'RNANews']
},
type: 'umd',
umdNamedDefine: true,
umdNamedDefine: true
},
path: Path.resolve(projectFolder, targetFolder),
},
path: Path.resolve(projectFolder, targetFolder)
}

},
// Morningstar time series
Expand All @@ -143,10 +143,10 @@ const webpacks: Array<Configuration> = [
root: [root, 'MorningstarConnectors', 'TimeSeries']
},
type: 'umd',
umdNamedDefine: true,
umdNamedDefine: true
},
path: Path.resolve(projectFolder, targetFolder),
},
path: Path.resolve(projectFolder, targetFolder)
}

}
];
Expand Down Expand Up @@ -178,7 +178,7 @@ for (let webpack of webpacks.slice()) {
webpack.performance = {
...webpack.performance,
maxAssetSize: 1000000,
maxEntrypointSize: 1000000,
maxEntrypointSize: 1000000
};
webpacks.push(webpack);
}
Expand Down

0 comments on commit 7bc9204

Please sign in to comment.