Monday, March 27, 2023

ChatGPT in ESLint (I will soon lose my job, replaced by this little bastard...)

Question: 

 

please write a ESLint rule to flag as deprecated the usage of variable names like Button.size.NORMAL

Answer:


To write an ESLint rule to flag the usage of variable names like Button.size.NORMAL, you can use the following code:

vbnet

module.exports = {
  rules: {
    "no-deprecated-variable-name": {
      meta: {
        deprecated: true,
        type: "problem"
      },
      create: function(context) {
        return {
          MemberExpression(node) {
            const { object, property } = node;
            if (object.type === "Identifier" && object.name === "Button" &&
                property.type === "MemberExpression" && property.property.name === "NORMAL") {
              context.report({
                node: property.property,
                message: "The use of 'Button.size.NORMAL' is deprecated. Use a different value instead."
              });
            }
          }
        };
      }
    }
  }
};

This rule creates a new ESLint rule called no-deprecated-variable-name, which checks for the usage of Button.size.NORMAL variables. When the rule encounters this variable, it reports a warning message to the user indicating that the usage of this variable is deprecated and suggests using a different value instead.

To use this rule, you will need to add it to your .eslintrc configuration file:

json

{
  "rules": {
    "no-deprecated-variable-name": "warn"
  }
}

In this configuration, the rule is set to "warn", which means it will produce a warning message but will not fail the build. You can set it to "error" to make it fail the build.




Sunday, March 19, 2023

Reverse Proxy with Docker httpd container on Windows

 https://www.middlewareinventory.com/blog/docker-reverse-proxy-example/

 

I have followed these instructions for Windows and it works, the only change I had to do is to start the container with the  "--net=host" options, and from the container I had to configure the ReverseProxyPass to use the IP address of the host (NOT the WSL IP).



Reverse Proxy with Spring Boot

https://github.com/vernetto/myreverseproxy/blob/master/src/main/java/org/pierre/myreverseproxy/CharonConfiguration.java 

 

I really like the simplicity and power of this CHARON, a Spring Boot- based Swiss knife for load balancing and request forwarding. 

 

Here a lot more examples https://github.com/mkopylec/charon-spring-boot-starter/blob/master/charon-spring-webmvc/src/test/java/com/github/mkopylec/charon/test/ReverseProxyConfiguration.java