babel-plugin-log-deprecated icon indicating copy to clipboard operation
babel-plugin-log-deprecated copied to clipboard

Add an option to print console.warn only once per function

Open gajus opened this issue 9 years ago • 0 comments

Some functions produce a lot of noise in the console.log as a result of the added warnings. This can be alleviated using a construct such as:

+let uniqueIdentifierForFooConsoleWarn = false;

+function foo () {
+  if (!uniqueIdentifierForFooConsoleWarn) {
+    uniqueIdentifierForFooConsoleWarn = true;

    console.warn("Deprecated: Function \"foo\" is deprecated in /fixtures/preset-options/adds-console-warn-to-function-declaration/actual.js on line 4", {
      functionName: "foo",
      message: "Deprecated in favour of quux.",
      packageName: "bar",
      packageVersion: "1.0.0",
      scriptColumn: 0,
      scriptLine: 4,
      scriptPath: "fixtures/preset-options/adds-console-warn-to-function-declaration/actual.js"
    });
+  }

  bar();
};

gajus avatar Nov 27 '16 21:11 gajus