简体   繁体   中英

Javascript Lint Error

I have a small script in JS that is giving me annoying errors that I cannot spot.

(function () {
  'use strict';
  angular
    .module('frontend')
    .config(config);
  config.$inject = ['$logProvider'];
  function config($logProvider) {
    // Enable log
    $logProvider.debugEnabled(true);
  }
})();

They are related to code style with the functions:

  2:10  error  Missing space before function parentheses  space-before-function-paren
  9:1   error  Block must not be padded by blank lines    padded-blocks

Can anyone help me see what space is the error referring to?

The first error is flagging this line:

function config($logProvider) {

Your linter settings indicate that you need a space between function name and the parenthesis with the arguments, here is correct spacing:

function config ($logProvider) {

The second error indicates that you cannot have empty/commented lines as the first or last line in your blocks, which is triggered by this line:

// Enable log

Delete that comment, or add the comment to end of line in question:

$logProvider.debugEnabled(true); // Enable log

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM