GithubHelp home page GithubHelp logo

tscpp / knuckles Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 1.73 MB

Modern development toolkit for Knockout ๐Ÿ‘Š

Home Page: https://knuckles.elsk.dev

License: MIT License

JavaScript 4.35% Shell 0.14% TypeScript 91.68% HTML 0.53% CSS 1.31% SCSS 0.16% Vue 1.83%
knockout knockoutjs toolchain toolkit knockout-lint knockout-ssr vscode-knockout-binding-support eslint typescript

knuckles's Introduction

Knuckles: Development Toolkit for Knockout.js

GitHub Actions Workflow Status Coveralls GitHub License NPM Downloads

What is Knuckles?

Knuckles is a development toolkit designed to enhance the developer experience (DX) using Knockout.js. It offers a range of useful tools for analyzing and optimizing Knockout.js applications. Each tool is entirely standalone and can be used independently. See website โ€บ

No knockout without knuckles! ๐Ÿ‘Š

Features

Analyzer

The analyzer allows you to check for issues in Knockout views before production. It allows you to utilize external tools, such as TypeScript and ESLint, to check the bindings, while also providing a set of useful rules to catch common misstakes. Read more โ€บ

TypeScript

As a plugin to the analyzer, it can type-check the bindings in your Knockout views and provides a generated snapshot which other tools can use to provide type-aware analysis. Read more โ€บ

ESLint

As a plugin to the analyzer, it can lint bindings using existing rules for JavaScript and TypeScript (with type-aware rules). Read more โ€บ

SSR

Server-side rendering (SSR) allows you to render data into the view before handing it to the client to render. This can be used to greatly optimize runtime performance and SEO. Read more โ€บ

Editor Support

Implementaion currently only exists for VSCode.

The language server provides language features to Knockout views, such as "go to definition", highlighting, diagnostics (from analyzer).

License

All source code is licensed under the MIT license.

Versioning

Verions adhear to Semantic Versioning (SemVer) v2.0.0.

knuckles's People

Contributors

tscpp avatar github-actions[bot] avatar maskmaster avatar

Stargazers

 avatar

Watchers

 avatar  avatar

knuckles's Issues

Optimization

  • Shared context deconstruction for descendants.
  • Optional context transformation.
  • Preserve context when identical child binding context.

Parser crashes on invalid bindings

The current binding parser currently uses acorn and will fail if the binding doesn't have valid object syntax.

The below example will make the parser crash because it expected the property "text" to have a value.

<div data-bind="text: "></div>

This will cause the analyzer and other language features not working while writing code, and the analyzer not to spit out any other errors than parsing errors if a single binding is broken.

Bindings dependant on the value from other bindings

The options binding can specify any type as long as there is an optionsText binding defined. And, optionsText can only be defined if options is defined and is dependant on the type passed to the options binding.

Let's say that members has the type Member[]. optionsText should be able to infer type type Member from the options binding.

<div data-bind="
  options: members,
  optionsText: (member) => member.name
"></div>

Interfaces under 'ko' namespace are untyped

Example: Typescript reports ko.Observable as any, since the knockout module is not found (imported from index.d.ts).

It might be good idea to report the project's errors to be able to identify similar errors in surrounding files.

Roadmap

Continues from kolint/next#1.

Stage 3

Analyzer

  • Catch parsing errors in analyzer and report them as issues.
  • #3
  • #19
  • #27
  • #31

SSR

  • Allow to explicitly disable rendering with no-ssr directive.

TypeScript

Parser

Documentation

  • Update syntax for analyzer
  • #14
  • Docs is broken after added playground
  • Fix releases
  • Update docs for new syntax
  • README banner text should be converted to path
  • #44 (coveralls)
  • #43

Stage 4

  • Implement formatter

Analyzer

  • #65
  • #66
    • Rule for untyped $context with quick fix when automatic resolution is configured.
  • #67
    • Shared context deconstruction for descendants.
    • Optional context transformation.
    • Preserve context when identical child binding context.

TypeScript

  • Allow user to override default interop algorithm for view models.
  • #68

Future...

SSR

  • #70
  • Improve SSR CLI

Analyzer

TypeScript

Language Features

  • Go to Definition
  • Hover
  • Completion
  • Diagnostics
  • Go to Declaration
  • Go to Type Definition
  • Go to Implementation
  • Find References
  • Document Highlight
  • Document Symbols
  • Semantic Tokens
  • Code Action
  • Rename
  • Document Link
  • Inline Value
  • Inlay Hint
  • Signature Help
  • Formatting
  • Linked Editing Range

$data is deeply unwrapped

In a new binding context, $data is unwrapped with the same semantics as the toJs function instead of the unwrap.

Custom mapping preserving range position.

The problem with using source maps is that it will always map to the beginning of the mapping. I need the mapping to preserve the local position within the range so the language server can correctly translate the position in the generated file.

Report tricky use case of calling a method on another viewmodel

Consider this code:

<div data-bind="click: $parent.closeModal">...</div>

When the function closeModal is called on $parent, it's going to have a wrong and unexpected this.

The correct code in this case is:

<div data-bind="click: $parent.closeModal.bind($parent)">...</div>

I think it's also something KOLint could report

kolint/kolint#341

Changes to 'strict' and 'loose' mode

  • Strict
    • Disallow anything that is not a boolean to conditional binding handlers.
    • Only allow string for "value" binding handler.
    • Strictly type hasFocus, checked, checkedValue, options, selectedOptions, template.
  • Loose
    • Context data and parents typed any by default.
    • Allow usage of undefined binding handlers via index access with loose default binding handler.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.