Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting issues #28

Open
supasate opened this issue Sep 29, 2016 · 10 comments
Open

Fix linting issues #28

supasate opened this issue Sep 29, 2016 · 10 comments

Comments

@supasate
Copy link
Contributor

No description provided.

@iswanj
Copy link
Contributor

iswanj commented Sep 29, 2016

@supasate I'll take this

@supasate
Copy link
Contributor Author

@iswanj Go for it

@iswanj
Copy link
Contributor

iswanj commented Sep 29, 2016

@supasate I found lint issue in messenger.js. There is lint rule for no-console, so I can dissable lint warn for these specific lines. or is there any other solution ?

if (!error && response.statusCode === 200) {
    console.log('Successfully sent generic message ' +
            `with id ${body.message_id} to recipient ${body
body.recipient_id}`);
} else {
    console.error('Unable to send message.');
    console.error(response);
    console.error(error);
}

@supasate
Copy link
Contributor Author

This repo still uses console a lot. So, I think you can disable it in .eslintrc for now. We may refactor it later.

@iswanj
Copy link
Contributor

iswanj commented Sep 30, 2016

@supasate

refreshToken() {
    // TO-DO: Call /token/auth/refresh instead
    const app = feathers()
      .configure(hooks())
      .configure(rest(this.uri).superagent(request))
      .configure(authentication());

    new Promise((resolve, reject) => {
      app.authenticate({
        type: 'local',
        'email': this.username,
        'password': this.password
      }).then(result => {
        this.token = app.get('token');
        resolve(this);
      }).catch(error => {
        console.log(error);
        reject(error);
      });
    });
  }

Inside refreshToken function, getting an eslint warn for "no-new" ( Do not use new for side effects ). So I'm gonna ignore "no-new" rull, any thoughts...?

@iswanj
Copy link
Contributor

iswanj commented Sep 30, 2016

Also found another error "Fatal Parsing error: Unexpected token" on
let context = await (conversation.getContext(userid));
on this line

@ephys
Copy link

ephys commented Sep 30, 2016

@iswanj The "no new for side effect" warning is there because wrapping the call to app.authenticate in a promise is useless (as app.authenticate already returns a Promise, plus the resulting promise is unused). The code could be written like this:

app.authenticate({
  type: 'local',
  'email': this.username,
  'password': this.password
}).then(result => {
  this.token = app.get('token');
}).catch(error => {
  console.log(error);
});

@supasate
Copy link
Contributor Author

supasate commented Oct 1, 2016

@iswanj For parsing error of await, you can eslint-disable-line.

The reason is we use asyncawait which async and await are functions that take another functions as arguments. (They just make them look alike keywords but they are, literally, functions).

That's different from async and await in ES7 which are keywords.

Therefore, eslint expects the following ES7 format:

onMessaged: async (event) => {
  ...
  await conversation.getContext(userid)
}

We may refactor it later when we move to ES7.

@iswanj
Copy link
Contributor

iswanj commented Oct 1, 2016

@supasate I think eslint-disable-line is working for the rules only.

@supasate
Copy link
Contributor Author

supasate commented Oct 1, 2016

You're right. So, I think we can left it unless we find a workaround.

supasate added a commit that referenced this issue Oct 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants