Issue Regarding Eslint in Meteor


#1

I have setup simple meteor todo app and also setup Eslint according to instruction given by http://www.meteor-tuts.com/chapters/3/linting.html

I have followed some steps:-

1> Run command:-

meteor npm i --save-dev babel-eslint eslint eslint-plugin-import eslint-plugin-meteor eslint-plugin-react eslint-import-resolver-meteor lint-staged pre-commit

2> Created .eslintrc.js file inside project root:

module.exports = {
    "parser": "babel-eslint",
    "parserOptions": {
        "allowImportExportEverywhere": true,
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "env": {
        "es6":     true,
        "browser": true,
        "node":    true,
    },
    "plugins": [
        "meteor",
        "react"
    ],
    "extends": ["eslint:recommended", "plugin:meteor/recommended", "plugin:react/recommended"],
    "settings": {
        "import/resolver": "meteor"
    },
    "rules": {
        "react/jsx-filename-extension": [1, {
            "extensions": [".jsx"]
        }],
        "react/jsx-no-bind": [2, {
            "ignoreRefs": false,
            "allowArrowFunctions": false,
            "allowFunctions": false,
            "allowBind": false
        }],
        "max-len": [0, {code: 100}],
        "import/no-absolute-path": [0],
        "meteor/audit-argument-checks": [0],
        "indent": ["error", 4],
        "switch-colon-spacing": [0],
        "no-invalid-this": [0],
        "new-cap": [1],
        "no-trailing-spaces": [2, {
            skipBlankLines: true
        }],
    },
    "overrides": {
        files: "*.js,*.jsx",
    }
};

3> In package.json file added the following:

{
  ...
  "scripts": {
    "start": "meteor run --settings settings.json",
    "test": "meteor test --driver-package practicalmeteor:mocha --settings settings.json",
    "lint": "eslint . --ext .jsx --fix"
  },
  "lint-staged": {
    "*.js": "eslint --fix",
    "*.jsx": "eslint --fix"
  },
  "pre-commit": "lint-staged",
  "pre-commit": {
    "silent": false
  },
  "precommit.silent": false
}

After that when i try to commit code by git commit -m “xxx”, it gives some error:-

W20180727-15:53:13.747(5.5)? (STDERR) "[object Object]" reporter blew up with error:
W20180727-15:53:13.764(5.5)? (STDERR) AssertionError [ERR_ASSERTION]: path must be a string
W20180727-15:53:13.765(5.5)? (STDERR)     at Module.require (module.js:595:3)
W20180727-15:53:13.765(5.5)? (STDERR)     at require (internal/module.js:11:18)
W20180727-15:53:13.765(5.5)? (STDERR)     at Mocha.reporter (/home/deligence/.meteor/packages/practicalmeteor_mocha-core/.1.0.1.m6yca6.qxn2++os+web.browser+web.cordova/npm/node_modules/mocha/lib/mocha.js:167:21)
W20180727-15:53:13.765(5.5)? (STDERR)     at MochaRunner.coffee.js.MochaRunner.runServerTests (packages/practicalmeteor_mocha/meteor/src/lib/MochaRunner.coffee:72:19)
W20180727-15:53:13.765(5.5)? (STDERR)     at MochaRunner.runServerTests (packages/practicalmeteor_mocha/meteor/src/lib/MochaRunner.coffee:1:1)
W20180727-15:53:13.765(5.5)? (STDERR)     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1767:12)
W20180727-15:53:13.765(5.5)? (STDERR)     at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
W20180727-15:53:13.766(5.5)? (STDERR)     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12)
W20180727-15:53:13.766(5.5)? (STDERR)     at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
W20180727-15:53:13.766(5.5)? (STDERR)     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12)
W20180727-15:53:13.766(5.5)? (STDERR)     at Promise (packages/ddp-server/livedata_server.js:715:46)
W20180727-15:53:13.766(5.5)? (STDERR)     at new Promise (<anonymous>)
W20180727-15:53:13.766(5.5)? (STDERR)     at Session.method (packages/ddp-server/livedata_server.js:689:23)
W20180727-15:53:13.766(5.5)? (STDERR)     at packages/ddp-server/livedata_server.js:559:43
I20180727-15:53:13.767(5.5)? Exception while invoking method 'mocha/runServerTests' Error: invalid reporter "[object Object]"
I20180727-15:53:13.767(5.5)?     at Mocha.reporter (/home/deligence/.meteor/packages/practicalmeteor_mocha-core/.1.0.1.m6yca6.qxn2++os+web.browser+web.cordova/npm/node_modules/mocha/lib/mocha.js:180:13)
I20180727-15:53:13.767(5.5)?     at MochaRunner.coffee.js.MochaRunner.runServerTests (packages/practicalmeteor_mocha/meteor/src/lib/MochaRunner.coffee:72:19)
I20180727-15:53:13.767(5.5)?     at MochaRunner.runServerTests (packages/practicalmeteor_mocha/meteor/src/lib/MochaRunner.coffee:1:1)
I20180727-15:53:13.767(5.5)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1767:12)
I20180727-15:53:13.767(5.5)?     at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
I20180727-15:53:13.767(5.5)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12)
I20180727-15:53:13.767(5.5)?     at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
I20180727-15:53:13.768(5.5)?     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1304:12)
I20180727-15:53:13.768(5.5)?     at Promise (packages/ddp-server/livedata_server.js:715:46)
I20180727-15:53:13.768(5.5)?     at new Promise (<anonymous>)
I20180727-15:53:13.768(5.5)?     at Session.method (packages/ddp-server/livedata_server.js:689:23)
I20180727-15:53:13.768(5.5)?     at packages/ddp-server/livedata_server.js:559:43
=> Meteor server restarted

Eslint error produced at the time of commit

Please suggest.

Screenshot:


#2

It seems to be linting meteor’s built files and packages too. Try adding a file to project root named .eslintignore, with the following content:

node_modules
.meteor