es-lint error can ot be disabled in react

Viewed 20

I had an eslint error when I try to commit the branch

147:14  error    Expected an assignment or function call and instead saw an expression
@typescript-eslint/no-unused-expressions

I can not find the problem in the code, also I tried to add

// eslint-disable-next-line no-unused-expressions

or

/* eslint-disable no-unused-expressions */

But still got the same error

 useEffect(() => {
    const setFile:any = []
    const addedFiles:any = acceptedFiles && acceptedFiles.map((item:File) => {
      if(item !== null){
        return {
          title: item?.name as string,
          fileName: item?.name as string,
          mediaType: 'SO',
          compositionType: 'O',
          album: ''
        };
      }else {[]}
    });
    setFile.push(addedFiles)
    if(addedFiles){ // **** the line 147
      setFileList([...addedFiles, ...fileList])
    }
    acceptedFiles && acceptedFiles.map((item:File) => {
      onUpload({
      title: item?.name as string,
      fileName: item?.name as string,
      mediaType: 'SO',
      compositionType: 'O',
      album: ''
    });
    })
  }, [acceptedFiles]);

  return (...
1 Answers

You forgot to prefix the rule name with @typescript-eslint/.

To disable that rule inline use:

// eslint-disable-next-line @typescript-eslint/no-unused-expressions

Alternatively, in your .eslintrc file, disable the rule with the setting

"@typescript-eslint/no-unused-expressions": "off"
Related