You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 18, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 18, 2026. It is now read-only.
Current behavior
For example, Durandal is installed, and if you are using Durandal with any framework, you need to specify every component and page's view models.
Expected behavior
Maybe if I could specify a framework and send it to KOLint, so it would automatically pull in the expected view model.
Example scenario. I have a view in "app/views/view1.html" and it's corresponding viewmodel in "app/views/view1.ts".
I am using requirejs to load the viewmodel, loading it via the module path "viewmodels/view1".
I have also set up a corresponding path in tsconfig.json.
Durandal uses a convention to find the corresponding view by replacing "viewmodels" with "views" in the module path.
We have a couple of things that complicates matters. Typically in tsconfig we only have paths set up for the ts modules. Therefore, ts have no means to resolve a module id "app/views/view1" for example. The second problem is that modules imported via two different paths are considered to separate modules. Therefore a module id "app/viewmodels/view1" and the same module identified by it's absolute file path, like "/project/src/viewmodels/view1" will be two disctinct modules. We need to be consistent in using logical module paths/ids or file paths. Usually a project will use module paths.
In this case i propose that we use the logical viewmodel id/path in requests to the knockout-lint cli. The cli resolves the module path against TS to it's physical file path. The module path and the resolved physical path are both sent to a callback registered in a kolintrc.js-file where we can create user-provided resolutions (all depending on what framework/library is used, conventions in finding). The user-provided algorithm could use either the physical path or the module path to generate it's view-path. The end result from the user provided hook should be both the "module path" to the HTML file along with the HTML file contents (it could be generated or fetched from completely different places.
The "module path" could be a physical path to the HTML file, or possibly a module id/path that is e.g. resolved by a web browser when locating the HTML file via a sourcemap.
# knockout-lint --viewmodel 'viewmodels/view1 --base .
The CLI uses TS and the tsconfig.json in the current directory '.' to resolve 'viewmodels/view1' to the physical path '/project/src/viewmodels/view1'.
@maskmaster In the case of using the "viewmodel" flag to the cli, should the cli only allow one viewmodel per flag, and should the viewmodel flag be able to be used multiple times?
Activity
maskmaster commentedon Dec 19, 2020
Example scenario. I have a view in "app/views/view1.html" and it's corresponding viewmodel in "app/views/view1.ts".
We have a couple of things that complicates matters. Typically in tsconfig we only have paths set up for the ts modules. Therefore, ts have no means to resolve a module id "app/views/view1" for example. The second problem is that modules imported via two different paths are considered to separate modules. Therefore a module id "app/viewmodels/view1" and the same module identified by it's absolute file path, like "/project/src/viewmodels/view1" will be two disctinct modules. We need to be consistent in using logical module paths/ids or file paths. Usually a project will use module paths.
In this case i propose that we use the logical viewmodel id/path in requests to the knockout-lint cli. The cli resolves the module path against TS to it's physical file path. The module path and the resolved physical path are both sent to a callback registered in a kolintrc.js-file where we can create user-provided resolutions (all depending on what framework/library is used, conventions in finding). The user-provided algorithm could use either the physical path or the module path to generate it's view-path. The end result from the user provided hook should be both the "module path" to the HTML file along with the HTML file contents (it could be generated or fetched from completely different places.
The "module path" could be a physical path to the HTML file, or possibly a module id/path that is e.g. resolved by a web browser when locating the HTML file via a sourcemap.
# knockout-lint --viewmodel 'viewmodels/view1 --base .The CLI uses TS and the tsconfig.json in the current directory '.' to resolve 'viewmodels/view1' to the physical path '/project/src/viewmodels/view1'.
The .kolintrc.js:
will produce the resulting context object
tscpp commentedon Dec 29, 2020
@maskmaster In the case of using the "viewmodel" flag to the cli, should the cli only allow one viewmodel per flag, and should the viewmodel flag be able to be used multiple times?
tscpp commentedon Jun 4, 2021
A function to handle view models for views could be implemented to the compiler host proposed in #281.