mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
[js] optimize eslint config (#18460)
### Description optimize eslint config to: - set parserOptions.project to `true` to allow @typescript-eslint/parser to find the nearest tsconfig.json file to that source file. This helps to avoid parsing extra files, may helps with: - reduce the possibility of seeing OOM or stackoverflow with "npm run lint" - faster processing - enforce rule "no-underscore-dangle" with a list of exceptions.
This commit is contained in:
parent
1dd9bf5340
commit
247ce21859
3 changed files with 68 additions and 18 deletions
|
|
@ -5,10 +5,18 @@
|
|||
|
||||
module.exports = {
|
||||
root: true,
|
||||
ignorePatterns: ['**/*.js', 'ort-schema/', 'common/test/type-tests/', 'test/data/', 'node_modules/', 'dist/'],
|
||||
ignorePatterns: [
|
||||
'**/*.js',
|
||||
'node_modules/',
|
||||
'ort-schema/',
|
||||
'common/test/type-tests/',
|
||||
'web/types.d.ts',
|
||||
'test/data/',
|
||||
'dist/',
|
||||
],
|
||||
env: { 'es6': true },
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: { 'project': 'tsconfig.json', 'sourceType': 'module' },
|
||||
parserOptions: { 'project': true, 'sourceType': 'module' },
|
||||
plugins: ['@typescript-eslint', 'prefer-arrow', 'header', 'import', 'unicorn', 'jsdoc'],
|
||||
rules: {
|
||||
'unicorn/filename-case': 'error',
|
||||
|
|
@ -144,15 +152,56 @@ module.exports = {
|
|||
'no-unused-expressions': 'off',
|
||||
}
|
||||
}, {
|
||||
files: ['web/lib/**/*.ts'],
|
||||
excludedFiles: 'web/lib/wasm/proxy-worker/**/*',
|
||||
parserOptions: { 'project': 'web/tsconfig.json' },
|
||||
rules: {
|
||||
'no-underscore-dangle': 'off',
|
||||
files: ['web/lib/**/*.ts'], rules: {
|
||||
'no-underscore-dangle': ['error', {
|
||||
'allow': [
|
||||
'_free',
|
||||
'_malloc',
|
||||
'_JsepGetNodeName',
|
||||
'_JsepOutput',
|
||||
'_OrtAddFreeDimensionOverride',
|
||||
'_OrtAddRunConfigEntry',
|
||||
'_OrtAddSessionConfigEntry',
|
||||
'_OrtAppendExecutionProvider',
|
||||
'_OrtBindInput',
|
||||
'_OrtBindOutput',
|
||||
'_OrtClearBoundOutputs',
|
||||
'_OrtCreateBinding',
|
||||
'_OrtCreateRunOptions',
|
||||
'_OrtCreateSession',
|
||||
'_OrtCreateSessionOptions',
|
||||
'_OrtCreateTensor',
|
||||
'_OrtEndProfiling',
|
||||
'_OrtFree',
|
||||
'_OrtGetInputName',
|
||||
'_OrtGetInputOutputCount',
|
||||
'_OrtGetLastError',
|
||||
'_OrtGetOutputName',
|
||||
'_OrtGetTensorData',
|
||||
'_OrtInit',
|
||||
'_OrtReleaseBinding',
|
||||
'_OrtReleaseRunOptions',
|
||||
'_OrtReleaseSession',
|
||||
'_OrtReleaseSessionOptions',
|
||||
'_OrtReleaseTensor',
|
||||
'_OrtRun',
|
||||
'_OrtRunWithBinding',
|
||||
'_OrtTrainingCopyParametersFromBuffer',
|
||||
'_OrtTrainingCopyParametersToBuffer',
|
||||
'_OrtTrainingCreateSession',
|
||||
'_OrtTrainingEvalStep',
|
||||
'_OrtTrainingGetModelInputOutputCount',
|
||||
'_OrtTrainingGetModelInputOutputName',
|
||||
'_OrtTrainingGetParametersSize',
|
||||
'_OrtTrainingLazyResetGrad',
|
||||
'_OrtTrainingLoadCheckpoint',
|
||||
'_OrtTrainingOptimizerStep',
|
||||
'_OrtTrainingReleaseCheckpoint',
|
||||
'_OrtTrainingReleaseSession',
|
||||
'_OrtTrainingRunTrainStep'
|
||||
]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
files: ['web/lib/wasm/proxy-worker/**/*.ts'],
|
||||
parserOptions: { 'project': 'web/lib/wasm/proxy-worker/tsconfig.json' },
|
||||
}, {
|
||||
files: ['web/lib/onnxjs/**/*.ts'], rules: {
|
||||
// TODO: those rules are useful. should turn on them in future (webgl refactor)
|
||||
|
|
@ -164,6 +213,7 @@ module.exports = {
|
|||
'import/no-internal-modules': 'off',
|
||||
'prefer-arrow/prefer-arrow-functions': 'off',
|
||||
'no-param-reassign': 'off',
|
||||
'no-underscore-dangle': 'off',
|
||||
'guard-for-in': 'off'
|
||||
}
|
||||
}, {
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ class AttributeWithCacheKeyImpl {
|
|||
Object.assign(this, attribute);
|
||||
}
|
||||
|
||||
private _cacheKey: string;
|
||||
private key: string;
|
||||
public get cacheKey(): string {
|
||||
if (!this._cacheKey) {
|
||||
this._cacheKey =
|
||||
if (!this.key) {
|
||||
this.key =
|
||||
Object.getOwnPropertyNames(this).sort().map(name => `${(this as Record<string, unknown>)[name]}`).join(';');
|
||||
}
|
||||
return this._cacheKey;
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ class AttributeWithCacheKeyImpl {
|
|||
Object.assign(this, attribute);
|
||||
}
|
||||
|
||||
private _cacheKey: string;
|
||||
private key: string;
|
||||
public get cacheKey(): string {
|
||||
if (!this._cacheKey) {
|
||||
this._cacheKey =
|
||||
if (!this.key) {
|
||||
this.key =
|
||||
Object.getOwnPropertyNames(this).sort().map(name => `${(this as Record<string, unknown>)[name]}`).join(';');
|
||||
}
|
||||
return this._cacheKey;
|
||||
return this.key;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue