How to set highlight to line?

if (view) {
      const currentHead = view.state.selection.main.head; // position of selection
      const line = view.state.doc.lineAt(currentHead).number; // line number
      // TODO: set highlight to the whole line.
      console.log('-- check --: ', line, event);
    }

I’ve got line number, and I want to set highlight to the whole line,how to do that ?

You should add line decoration, as described: CodeMirror Decoration Example

Depending on your usecase you can either calculate the line to highlight, or you can store the value in StateField.