Giter Site home page Giter Site logo

metal-soy-critic's Introduction

metal-soy-critic

Note: the metal-soy-critic project has been moved to the metal-tools-soy repo.

To simplify development and maintenance and handle all tools-soy projects, this project has been moved to the metal-soy-critic under the umbrella of the metal-tools-soy monorepo.

metal-soy-critic's People

Contributors

jbalsas avatar ethib137 avatar matuzalemsteles avatar mthadley avatar

Stargazers

Jorge González avatar RAVI MISHRA avatar Albertinin Mourato Santos avatar Aline D'Oleron Cantarelli avatar Pier Paolo Ramon avatar Adriano Interaminense avatar  avatar Fernando Souza avatar Bryce Osterhaus avatar Eduardo Lundgren avatar Ruben Pulido avatar

Watchers

Fernando Souza avatar James Cloos avatar Shinn Lok avatar  avatar  avatar Carlos Lancha avatar  avatar

metal-soy-critic's Issues

These params can't be found in STATE or your Class:

If I have class A, that extends class B, and the soy template for A implements STATE params from B it will show the following error.

These params can't be found in STATE or your Class:

The parent class needs to be resolved and parsed as well. Obviously that makes things a lot more complicated :)

Fails to throw an error when no namespace is declared in a soy file that does not have a corresponding js file.

  1. Create a soy file without a namespace declaration.
/**
 * LinkSpan
 */
{template .render}
	{@param attributes: attributes}
	{@param? content: html|string}
	{@param? span: bool}

	{if $span}
		<span {$attributes}>{$content}</span>
	{else}
		<a {$attributes}>{$content}</a>
	{/if}
{/template}
  1. Do not create a js file.
  2. Run mcritic.

Expected result: MCritic throws an error declaring that you have not written valid soy.

Actual result: MCritic does not throw an error.

Allow for a metal-soy-critic config file.

We have a few cases where configuration makes sense for metal-soy-critic. One use case is allowing for a custom regex when determining the matching import path for a component having it's render template called.

Let's go with a config file like .soycriticrc or soycritic.config.js. The CLI can recursively look in parent directories for this file, and read it's configuration when one is found.

/cc @jbalsas

Feedback for parsed files that have no issues

Hey guys, awesome idea for a tool!

The first time I ran it on a file, it didn't find any issues so there was no output. This made me think it was potentially a bug, and I wasn't sure if it actually read the file or not.

It might be nice to have output that lists all files that pass your checks, similar to test output which lists both the tests that pass and the ones that fail. Maybe something like...

The following 1 file(s) passed all checks:

File - src/SomeFile.soy

Recursive configuration

Currently, mcritic stops at the first occurrence of a config file. This makes it impossible to override default settings in specific areas of the code. Given the following layout:

  • root
    • .soycriticrc.json
    • src
    • test
      • .soycriticrc.json

Soy files within the test folder will be linted using the root configuration rather than by the mix of both.

Multiple soyToImport configs

Currently, we support just one pair

  "callToImportRegex": "(\\S+)",
  "callToImportReplace": "{$1|param}"

This can be problematic if different types of imports are mixed in the same project, making it really hard to adapt. We could try to

Have synced arrays

callToImportRegex: string|array<string>
callToImportReplace: string|array<string>

Or move this directly to an array of regex,replace pairs

callToImport: [
    {
        regex: /regex1/,
        replace: 'replace1'
    }, {
        regex: /regex2/,
        replace: 'replace2'
    }
]

I'm not sure if anyone other than us is using the old syntax. The new one feels more robust. We could try to deprecate the old one, or just break it and release a major change if we don't care about maintaining that.

Thoughts, @Robert-Frampton, @mthadley?

Missing import imcompatible with unused variable

We are currently looking for imports in a componente when a template is used, so if you're using {call Dropdown.render} we're looking (I guess ) for an import Dropdown from... statement.

If not found, we have get the following message:

File - src/main/resources/META-INF/resources/components/configurabledropdown/ConfigurableDropdown.soy

     It looks like the following component calls are missing an import:
     
     Dropdown

This is incompatible with estlint::unused-var rule, so we usually have

import metal-dropdown // avoid declaring Dropdown when not used

Allow for use as a Library.

We should export some functions that allows using metal-soy-critic as a library. We will probably need to update some of the return types so that they make sense for more generic use cases.

We can also consider adding a JSON output option. This would be useful for integration with tools like linters, continuous integration, etc.

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.