Optical Incremental Encoder Reading using Arduino UNO
You are attaching your interrupt incorrectly. You should not pass in the pin number, but the interrupt number. There is also a handy function that converts a pin to the right interrupt number:

attachInterrupt(digitalPinToInterrupt(pin), ISR, mode);


So, your code should be:

attachInterrupt(digitalPinToInterrupt(encoderPinA), isr,CHANGE);


Also, you should declare your counter variable to be volatile, since it is modified within an ISR, and thus the compiler should not assume that it doesn't change even though the loop() never changes it:

volatile int counter = 0;