Giter Site home page Giter Site logo

teppeis / fixclosure Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 7.0 1.78 MB

JavaScript dependency checker/fixer for Closure Library based on ECMAScript AST

Home Page: https://npm.im/fixclosure

License: MIT License

JavaScript 0.89% TypeScript 99.11%
closure-library linter javascript

fixclosure's People

Contributors

ama-ch avatar gorohash avatar greenkeeperio-bot avatar koba04 avatar piglovesyou avatar renovate[bot] avatar smaren avatar teppeis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fixclosure's Issues

fixclosure sometimes counts an object as 'toRequire'.

This test fails.

/**
 * @param {Element} e An click event.
 */
goog.Foo1.prototype.handleClick = function(e) {
  if (e.target && e.target.id == 'XX') { }
};

// toProvide: goog.Foo1

fixclosure reports Missing Require: e.target but we never want.

Add option to ignore provides

Currently, we are not interested in changing provides. Fx, whether an enum on a class should be provided varies by case. Having an option to leave provides as they are would be nice.

replaceMap contains wrong default values

The replaceMap contains a value from goog.disposeAll to goog.dispose. However, goog.disposable provides goog.disposeAll so it should not be changed to something different. Is the replaceMap relevant at all if you are using a deps file? I think it is a similar case to providedNamespaces which is now deprecated in favor of --depsJs.

Don't require resources defined in the same file

This goog.dom.SavedRange.logger_ should not be goog.required.

goog.dom.SavedRange.logger_ =
    goog.debug.Logger.getLogger('goog.dom.SavedRange');

goog.dom.SavedRange.prototype.restore = function(opt_stayAlive) {
  goog.dom.SavedRange.logger_.severe(
      'Disposed SavedRange objects cannot be restored.');
  // ...
};

Inconsistent output with README.md

I’ve tried fixclosure with a file that is the same as an example in README.md.
But the result was unexpected for me.
Am I missing something?

  • Input File
// foo.js (before)
goog.provide('goog.foo.Bar');

goog.require('goog.foo');
goog.require('goog.unused');

goog.foo.Bar = function() {
  goog.foo.baz();
  goog.missing.require();
};
  • Expected
File: foo.js

Provided:
- goog.foo.Bar

Required:
- goog.foo
- goog.unused

Missing Require:
- goog.missing

Unnecessary Require:
- goog.unused

FAIL!

Total: 1 files
Passed: 0 files
Failed: 1 files
  • Actual
File: foo.js

Provided:
- goog.foo.Bar

Required:
- goog.foo
- goog.unused

Unnecessary Require:
- goog.foo
- goog.unused

FAIL!

Total: 1 files
Passed: 0 files
Failed: 1 files

Inline hint "fixclosure: ignore"

goog.provide('goog.undefined.in.this.file'); // fixclosure: ignore
goog.require('goog.unused.in.this.file'); // fixclosure: ignore

Merge with suppressUnused

A comment below an `@extends` tag invalidates requires

/**
 * @interface
 * @extends {goog.Foo}
 * I am a comment
 */

goog.Foo should be required, but it is not.

Likewise:

/**
 * @interface
 * @extends {goog.Foo}
 * @extends {goog.Foo2}
 * I am a comment
 * @extends {goog.Foo3}
 * @extends {goog.Foo4}
 */

Here goog.Foo is required, but none of the others are.

node-version

We are currently restricted to using a node version <10 since we are using gulp v3. Specifically, we are using node 8. We are currently using our own private fork of fixclosure to validate requires, and in that fork the node version is set to >=8, and it seems to work without any issues. Is there a specific reason you have set "node": ">=10"? Would you be ok with downgrading to "node": ">=8"?

.fixclosurerc merged incorrectly

When the command line options is merged with the config options, the argsOptions will have default values even if they are not set. So if I call fixclosure path/to/file, the argsOptions will have default values for --useForwardDeclare so it cannot be overridden from the .fixclosurerc file.
The --depsJs argument is parsed in a different way. It creates an array of namespaces based on the passed deps file. However, when the merged options object is created it will always use the one created from the argsOptions object even if that list is empty and the rcOptions contains correct namespaces.

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.