teppeis / fixclosure Goto Github PK
View Code? Open in Web Editor NEWJavaScript dependency checker/fixer for Closure Library based on ECMAScript AST
Home Page: https://npm.im/fixclosure
License: MIT License
JavaScript dependency checker/fixer for Closure Library based on ECMAScript AST
Home Page: https://npm.im/fixclosure
License: MIT License
Since Closure Compiler v20210808, nested goog.provide
for @typedef
causes JSC_TYPEDEF_CHILD_OF_PROVIDE
error.
https://github.com/google/closure-compiler/wiki/Releases#august-8-2021-v20210808
Ban files with nested goog.provides where a nested goog.provide is used as a
@typedef
. If you see a newJSC_TYPEDEF_CHILD_OF_PROVIDE
error, the recommended fix is to delete the nested goog.provide (and optionally move to goog.module)
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.
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.
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
.
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.');
// ...
};
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?
// 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();
};
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
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
goog.provide('goog.undefined.in.this.file'); // fixclosure: ignore
goog.require('goog.unused.in.this.file'); // fixclosure: ignore
Merge with suppressUnused
/**
* @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.
When enabled, only adding missing goog.require
and no removing useless goog.require
.
Private classes should not be provided. like:
goog.dom.DomSavedMultiRange_ = function(range) {
// ...
};
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"
?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.