Why do I only get ESLint warnings during CRA build and not when running Eslint on the CLI? - create-react-app

I just inherited a Create React App based project and noticed something peculiar. When I run npx eslint src/ there are no issues. No output, nothing. Even introducing some errors seemed to make no difference! On the other hand, when doing npm start I can see lots of ESLint output in the console:
Compiled with warnings.
./src/Components/Exercises/Edit.tsx
Line 100:9: 'generateSubtypesList' is assigned a value but never used #typescript-eslint/no-unused-vars
./src/Components/Workouts/Table.tsx
Line 1280:45: Expected '===' and instead saw '==' eqeqeq
Line 1281:43: Expected '===' and instead saw '==' eqeqeq
./src/Components/Workouts/Edit.tsx
Line 12:3: 'TextField' is defined but never used #typescript-eslint/no-unused-vars
Line 381:6: React Hook React.useEffect has a missing dependency: 'delSuperSetList'. Either include it or remove the dependency array react-hooks/exhaustive-deps
./src/Components/Sessions/Edit.tsx
Line 130:6: React Hook React.useEffect has a missing dependency: 'delSuperSetList'. Either include it or remove the dependency array react-hooks/exhaustive-deps
./src/Components/Workouts/Add.tsx
Line 13:3: 'TextField' is defined but never used #typescript-eslint/no-unused-vars
Line 176:6: React Hook React.useCallback has a missing dependency: 'delSuperSetList'. Either include it or remove the dependency array react-hooks/exhaustive-deps
./src/Components/Workouts/ExerciseSetsList.tsx
Line 145:34: Expected '===' and instead saw '==' eqeqeq
Line 150:30: Expected '===' and instead saw '==' eqeqeq
Line 150:58: Expected '===' and instead saw '==' eqeqeq
./src/Components/Settings/Availability.tsx
Line 177:23: Expected '===' and instead saw '==' eqeqeq
...
What is happening here and how can I make ESLint output these warnings on the command line?
Manually adding ESLint v7 makes things work as expected?
So the strange thing I found is that if I do npm install eslint so that version 7 gets installed, everything works as expected:
$ node ./node_modules/react-scripts/node_modules/eslint/bin/eslint.js --version
v6.8.0
$ node ./node_modules/react-scripts/node_modules/eslint/bin/eslint.js src/
$ # nothing was found
$ node ./node_modules/eslint/bin/eslint.js --version
v7.32.0
$ node ./node_modules/eslint/bin/eslint.js src
/Users/my-user/dev/myproj-trainer-web/src/Components/Clients/Details.tsx
41:10 warning 'isPropertyDeclaration' is defined but never used #typescript-eslint/no-unused-vars
/Users/my-user/dev/myproj-trainer-web/src/Components/Exercises/Add.tsx
72:9 warning 'generateCategoryList' is assigned a value but never used #typescript-eslint/no-unused-vars
168:9 warning 'validateInput' is assigned a value but never used #typescript-eslint/no-unused-vars
/Users/my-user/dev/myproj-trainer-web/src/Components/Exercises/Details.tsx
8:10 warning 'ExerciseTypes' is defined but never used #typescript-eslint/no-unused-vars
9:8 warning 'CloseIcon' is defined but never used #typescript-eslint/no-unused-vars
/Users/my-user/dev/myproj-trainer-web/src/Components/Exercises/Edit.tsx
95:9 warning 'generateSubtypesList' is assigned a value but never used #typescript-eslint/no-unused-vars
/Users/my-user/dev/myproj-trainer-web/src/Components/Exercises/Listings.tsx
333:56 warning 'is_user_exercise' is assigned a value but never used #typescript-eslint/no-unused-vars
/Users/my-user/dev/myproj-trainer-web/src/Components/Menus/SubMenu.tsx
1:8 warning 'React' is defined but never used #typescript-eslint/no-unused-vars
2:10 warning 'NavLink' is defined but never used #typescript-eslint/no-unused-vars
/Users/my-user/dev/myproj-trainer-web/src/Components/Schedules/Details.tsx
3:10 warning 'format' is defined but never used #typescript-eslint/no-unused-vars
14:3 warning 'Info' is defined but never used #typescript-eslint/no-unused-vars
/Users/my-user/dev/myproj-trainer-web/src/Components/Sessions/Cancel.tsx
63:9 warning 'generateTimeToSession' is assigned a value but never used #typescript-eslint/no-unused-vars
/Users/my-user/dev/myproj-trainer-web/src/Components/Sessions/Details.tsx
504:18 warning Expected '===' and instead saw '==' eqeqeq
I don't really understand why version 6.8 keeps silent on the CLI, but not when interfacing with the CRA build?

Related

Successful build of Kicad 4.0.6 in Linux Mageia 5 via fixing a wx-3.0 symbol

I have managed to build the Kicad 4.0.6 in Linux Mageia 5.1 with gcc version 4.9.2. I first manually fixed two wxWidgets 3.0.2 header files in the /usr/include/wx-3.0/wx/ directory: regex.h and features.h. Kicad then compiled successfully. With the native wx-3.0 headers, the compiler generated the error in pcbnew/netlist_reader.cpp due to the undefined variable wxRE_ADVANCED.
The features.h header checks if the macro WX_NO_REGEX_ADVANCED is defined. If yes, features.h UNdefines wxHAS_REGEX_ADVANCED macro, and defines it, if no. The macro wxHAS_REGEX_ADVANCED, in turn, is used in regex.h to determine if among the enum constants wxRE_ADVANCED = 1 is present. The standard prebuilt Mageia 5 packages wxgtku3.0_0 and lib64wxgtku3.0-devel that I installed with the use of Mageia's software manager urpmi from Mageia repository WX_NO_REGEX_ADVANCED is defined, therefore wxHAS_REGEX_ADVANCED is undefined, and, hence, wxRE_ADVANCED is undefined either. Kicad 4.0.6 source package assumes wxRE_ADVANCED = 1, therefore the build process stops with the error.
Then I reverted /usr/include/wx-3.0/wx/regex.h and features.h to their original state and learned how to add the definition of wxRE_ADVANCED to CMakeLists.txt. However, I still have a question.
The recommended format of adding the definition to CMakeLists.txt I found at CMake command line for C++ #define is this:
if (NOT DEFINED wxRE_ADVANCED)
set(wxRE_ADVANCED 1)
endif()
add_definitions(-DwxRE_ADVANCED=$(wxRE_ADVANCED))
However, it did not work! The macro expansion for wxRE_ADVANCED in pcbnew/netlist_reader.cpp was empty. I printed it at compile time inserting the following lines into the netlist_reader.cpp file (this was hard to find, most of the recommended formats did not work. The correct one is in C preprocessor: expand macro in a #warning):
#define __STRINGIFY(TEXT) #TEXT
#define __WARNING(TEXT) __STRINGIFY(GCC warning TEXT)
#define WARNING(VALUE) __WARNING(__STRINGIFY(wxRE_ADVANCED = VALUE))
Pragma (WARNING(wxRE_ADVANCED))
Finally, I simplified the CMakeLists.txt definition down to this, and it was a success:
if (NOT DEFINED wxRE_ADVANCED)
set(wxRE_ADVANCED 1)
endif()
add_definitions(-DwxRE_ADVANCED=1)
My question: what is the meaning of "-DwxRE_ADVANCED=$(wxRE_ADVANCED)" if it does not work? Is it possible not to use set(wxRE_ADVANCED 1), and simply write add_definitions(-DwxRE_ADVANCED=1)? Thank you.
P.S. Yes, the Kicad 4.0.6 build process successfully finished with only one line added to the top level CMakeLists.txt file:
add_definitions(-DwxRE_ADVANCED=1)
A variable is called via $variable or ${variable}. Note the curly brackets, not parentheses.
Also, it is recommended to use:
target_compile_definitions(mytarget PUBLIC wxRE_ADVANCED=1)
on a target directly, rather than the general add_definitions() command.

How can a CMake variable be hidden?

I have a CMake project which lets a globally set variable (set with -DARDUINO_SDK_PATH=/a/b/c on command line) disappear i.e. suddenly the given value is gone which leads to a fatal error.
I know there are different ways to "hide" a variable (e.g. inside functions or external projects)
In my case:
the variable is not being set explicitly anywhere in the code (e.g. via set() or find_path())
the access which leads to the error is on top level (i.e. not inside a function)
there are instructions (i.e. same file/line) where in one case the variable has the value it's been given and the next time it's gone
Tracing the variable with variable_watch(ARDUINO_SDK_PATH) I can see that everything works fine before the compiler is being checked:
cmake -DARDUINO_SDK_PATH=/a/b/c <path>
...
... everything fine, ${DARDUINO_SDK_PATH} == '/a/b/c' everywhere
...
-- Check for working C compiler: /usr/bin/avr-gcc
...
... here the variable is empty and not being traced any more
...
Here is my suggestion:
Does the compiler check (indicated by check for working C compiler .. on the terminal) have it's own variable space and does not know variables provided on command line?
Note: This question is a generalization of this question, which has become way too specialized but might offer some useful background information.
That any modification to variable is not traced after the variable_watch() command seems like a bug somewhere in CMake to me.
Generally speaking a "cached CMake variable" can be hidden by a "normal CMake variable" with the same name. But e.g. find_path() won't run again or modify a variable if already set.
Here is an example:
cmake_minimum_required(VERSION 2.4)
project(VariableWatchTest NONE)
variable_watch(MY_TEST_VAR)
set(MY_TEST_VAR "something" CACHE INTERNAL "")
message("${MY_TEST_VAR}")
set(MY_TEST_VAR "hiding something")
message("${MY_TEST_VAR}")
unset(MY_TEST_VAR)
message("${MY_TEST_VAR}")
find_path(MY_TEST_VAR NAMES "CMakeLists.txt" HINTS "${CMAKE_CURRENT_LIST_DIR}")
message("${MY_TEST_VAR}")
Would give (without the variable_watch() messages:
-- something
-- hiding something
-- something
-- something
References
What's the CMake syntax to set and use variables?
I'm not sure whether this is a bug or a feature but (at least some) CMake variables are not available in certain steps of the CMake configuration procedure.
You can check this by adding something like this to your toolchain file:
MESSAGE("FOO: ${FOO}")
and run CMake like this
cd build-dir
cmake -DFOO=TEST ..
You will likely see FOO printed with value TEST once in the beginning of the configuration process and later printed again but being empty.
Just don't access variables from the global space inside a toolchain file (doesn't belong there anyway).

what does it mean `dotspacemacs-configuration-layers' was changed outside of `dotspacemacs/layers'?

My spacemacs is 0.200.3#25.1.1
I got a warning when launching spacemacs every time, how to fix this?
Warnings:
- dotspacemacs-configuration-layers' was changed outside of
dotspacemacs/layers'.
I have got the same warning after update to the recent version 0.200.5 but it was caused by following line in my .spacemacs, which was in dotspacemacs/user-config function:
(setq-default dotspacemacs-configuration-layers
'((auto-completion :variables
auto-completion-enable-snippets-in-popup t)))
In your case, please find all occurrences of dotspacemacs-configuration-layers variable in your config and move them into dotspacemacs/layers function in .spacemacs file.
As I understand, now Spacemacs requires to define dotspacemacs-configuration-layers variable only once in dotspacemacs/layers function.

Theos error: "Can't call method "isNew" on an undefined value at /var/mobile/sbtest1/theos/bin/logos.pl line 382."

I was wondering how I would fix this error in the Logos.pl file, this is what I'm getting:
WillPhone:/var/mobile/sbtest1 root# make package install
/var/mobile/sbtest1/theos/makefiles/targets/Darwin-arm/iphone.mk:43: Targeting iOS 4.0 and higher is not supported with iphone-gcc. Forcing clang.
Making all for tweak sbtest1...
Preprocessing Tweak.xm...
Constants from lexical variables potentially modified elsewhere are deprecated at /private/var/theos/bin/lib/aliased.pm line 42.
Constants from lexical variables potentially modified elsewhere are deprecated at /private/var/theos/bin/lib/aliased.pm line 42.
Constants from lexical variables potentially modified elsewhere are deprecated at /private/var/theos/bin/lib/aliased.pm line 42.
Constants from lexical variables potentially modified elsewhere are deprecated at /private/var/theos/bin/lib/aliased.pm line 42.
Constants from lexical variables potentially modified elsewhere are deprecated at /private/var/theos/bin/lib/aliased.pm line 42.
Constants from lexical variables potentially modified elsewhere are deprecated at /private/var/theos/bin/lib/aliased.pm line 42.
Constants from lexical variables potentially modified elsewhere are deprecated at /private/var/theos/bin/lib/aliased.pm line 42.
Constants from lexical variables potentially modified elsewhere are deprecated at /private/var/theos/bin/lib/aliased.pm line 42.
Can't call method "isNew" on an undefined value at /var/mobile/sbtest1/theos/bin/logos.pl line 382.
make[2]: *** [obj/Tweak.xm.a114fd55.o] Error 255
make[1]: *** [internal-library-all_] Error 2
make: *** [sbtest1.all.tweak.variables] Error 2'˚`
Thanks! - Will B
You can go to Theos Github to submit this issue.
Here are some other projects with this issue.I hope it will help you.
https://github.com/preaction/Statocles/issues/190
https://github.com/Crowdtilt/Business-BalancedPayments/issues/53

How to disable warning: Using 'stringWithString' with a literal is redundant?

Some old third party code gives warning:
Using 'stringWithString' with a literal is redundant
Instead of modifying the source codes, I'd prefer to disable the warning in Xcode. What is the compiler switch to disable this specific warning?
The warning message should tell you the name of the warning. You can then turn that warning off.
test.m:4:5: warning: using 'stringWithString:' with a literal is redundant
[-Wobjc-redundant-literal-use]
so you want to add the flag -Wno-objc-redundant-literal-use to the compiler flags for that file or that project.
One way to do that is :
Select your target .
Go to the compiled sources.
Select your .m file and set flag -w to suppress all the warning of that file .