Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js] optimize eslint config #18460

Merged
merged 4 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 60 additions & 10 deletions js/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Expand All @@ -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'
}
}, {
Expand Down
8 changes: 4 additions & 4 deletions js/web/lib/onnxjs/attribute-with-cache-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
8 changes: 4 additions & 4 deletions js/web/lib/wasm/jsep/webgpu/attribute-with-cache-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
Loading