Skip to content

Commit

Permalink
Added standard eslint config & updated code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Gloger committed Nov 9, 2016
1 parent 670ec4f commit b25702f
Show file tree
Hide file tree
Showing 42 changed files with 1,160 additions and 1,182 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = true

[*]
indent_style = space
indent_size = 4
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Expand Down
40 changes: 3 additions & 37 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
{
"ecmaFeatures": {
"arrowFunctions": true,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"forOf": true,
"generators": true,
"modules": false,
"templateStrings": true
},
"env": {
"node": true,
"es6": true,
"mocha": true
},
"globals": {
"module": true,
"console": true,
"process": true,
"require": true,
"__dirname": true,
"Promise": true, // So we can override it with npm package 'promise'
"describe": true,
"it": true
},
"extends": "standard",
"rules": {
"strict": [
2,
"global"
],
"no-underscore-dangle": 0,
"no-undef": 2,
"no-unused-vars": 1,
"quotes": [
2,
"single"
],
"semi": 1
"semi": [1, "always"],
"padded-blocks": 0
}
}
30 changes: 15 additions & 15 deletions examples/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@ const alexia = require('..');
const app = alexia.createApp('ActionsExample');

const intentA = app.intent('intentA', 'clear my calendar for {date:Date}', (slots) => {
return {
text: 'Are you sure you want to clear your calendar?',
attrs: {
date: slots.date
},
end: false
};
return {
text: 'Are you sure you want to clear your calendar?',
attrs: {
date: slots.date
},
end: false
};
});

// Or use built-in amazon intents. See: `examples/built-in-intents.js`
const intentB = app.intent('intentB', 'yes', (slots, attrs) => {
// Clear calendar for date `attrs.date` here
return 'Your calendar has been cleared';
// Clear calendar for date `attrs.date` here
return 'Your calendar has been cleared';
});

app.intent('intentC', 'no', () => {
return 'Your calendar was not modified';
});

app.action({
from: '*', // Allow transition from any intent to `intent1`. Use '@start' to allow intent only on start
to: 'intentA' // Refer to intent by its name or remember its reference. See below
from: '*', // Allow transition from any intent to `intent1`. Use '@start' to allow intent only on start
to: 'intentA' // Refer to intent by its name or remember its reference. See below
});

app.action({
from: intentA,
to: intentB,
if: (slots, attrs) => attrs.date, // Note: date should be validated here
fail: (slots, attrs) => 'Sorry, your command is invalid'
from: intentA,
to: intentB,
if: (slots, attrs) => attrs.date, // Note: date should be validated here
fail: (slots, attrs) => 'Sorry, your command is invalid'
});

app.defaultActionFail(() => 'Sorry, your request is invalid');
Expand Down
8 changes: 4 additions & 4 deletions examples/app-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const alexia = require('..');

// Create app with additional info (optional)
const app = alexia.createApp('AppInfoExample', {
version: '1.2.3',
ids: ['appId1', 'appId2']
version: '1.2.3',
ids: ['appId1', 'appId2']
});

app.intent('SampleIntent', 'sample', () => {
return 'Hello again';
return 'Hello again';
});

module.exports = app;
module.exports = app;
6 changes: 3 additions & 3 deletions examples/async-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const alexia = require('..');
const app = alexia.createApp('AsyncResponseExample');

app.intent('AsyncIntent', 'async', (slots, attrs, data, done) => {
setTimeout(() => {
done('Response here');
}, 120);
setTimeout(() => {
done('Response here');
}, 120);
});

module.exports = app;
4 changes: 2 additions & 2 deletions examples/custom-slots.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const app = alexia.createApp('CustomSlotsExample');
app.slot('Name', ['Foo', 'Bar']);

app.intent('CustomSlotIntent', 'My name is {name:Name}', (slots) => {
return `You sure your name is ${slots.name}?`;
return `You sure your name is ${slots.name}?`;
});

module.exports = app;
module.exports = app;
4 changes: 2 additions & 2 deletions examples/hello-world.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const alexia = require('..');
const app = alexia.createApp('HelloWorldExample');

app.intent('HelloIntent', 'hello', () => {
return 'Hello World!';
return 'Hello World!';
});

module.exports = app;
module.exports = app;
2 changes: 1 addition & 1 deletion examples/more-utterances.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const alexia = require('..');
const app = alexia.createApp('MoreUtterancesExample');

app.intent('MoreUtterancesIntent', ['hello sir', 'good evening sir', 'whats up'], () => {
return 'Hello yourself';
return 'Hello yourself';
});

module.exports = app;
4 changes: 2 additions & 2 deletions examples/original-request-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const alexia = require('..');
const app = alexia.createApp('OriginalRequestDataExample');

app.intent('OriginalRequestData', 'read original request data', (slots, attrs, data) => {
console.log('userId', data.session.user.userId);
return 'Hi';
console.log('userId', data.session.user.userId);
return 'Hi';
});

module.exports = app;
40 changes: 20 additions & 20 deletions examples/response-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ const alexia = require('..');
const app = alexia.createApp('ResponseObjectExample');

app.intent('SSMLIntent', 'response with ssml', () => {
return {
text: '<say-as interpret-as="cardinal">12345</say-as>',
ssml: true
};
return {
text: '<say-as interpret-as="cardinal">12345</say-as>',
ssml: true
};
});

app.intent('CardIntent', 'response with card', () => {
return {
text: 'Check out card in alexa app',
card: {
title: 'Card title',
content: 'Card content'
}
};
return {
text: 'Check out card in alexa app',
card: {
title: 'Card title',
content: 'Card content'
}
};
});

app.intent('RepromptIntent', 'response with reprompt', () => {
return {
text: 'I should reprompt you in a second',
reprompt: 'This is a reprompt'
};
return {
text: 'I should reprompt you in a second',
reprompt: 'This is a reprompt'
};
});

app.intent('KeepSessionIntent', 'keep session', () => {
return {
text: 'I should terminate this session',
end: false
};
return {
text: 'I should terminate this session',
end: false
};
});

module.exports = app;
module.exports = app;
30 changes: 15 additions & 15 deletions examples/session-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ const app = alexia.createApp('SessionAttributesExample');

// Store attribute
app.intent('AttrsIntent', 'My name is {name:Name}', (slots) => {
return {
text: `Hi ${slots.name}`,
attrs: {name: slots.name},
end: false
};
return {
text: `Hi ${slots.name}`,
attrs: {name: slots.name},
end: false
};
});

// Use attribute
app.intent('AttrsIntentTwo', 'What is my name', (_slots, attrs) => {
if(attrs.name) {
return `Your name is ${attrs.name}`;
} else {
return 'You are no one';
}
if(attrs.name) {
return `Your name is ${attrs.name}`;
} else {
return 'You are no one';
}
});

// Add another and keep previous attributes
app.intent('AttrsIntentThree', 'I am {age:Number} years old', (slots, attrs) => {
return {
text: `Hi ${slots.name}`,
attrs: Object.assign({}, attrs, {name: slots.age})
};
return {
text: `Hi ${slots.name}`,
attrs: Object.assign({}, attrs, {name: slots.age})
};
});

module.exports = app;
module.exports = app;
12 changes: 6 additions & 6 deletions examples/slots.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ const alexia = require('..');
const app = alexia.createApp('SlotsExample');

app.intent('SlotsIntent', 'I am {age:Number} years old', (slots) => {
if(slots.age) {
return `Hello person, you are ${slots.age} years old`;
} else {
return 'I did not catch your age';
}
if(slots.age) {
return `Hello person, you are ${slots.age} years old`;
} else {
return 'I did not catch your age';
}
});

// See: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interaction-model-reference#Slot%20Types

module.exports = app;
module.exports = app;
4 changes: 2 additions & 2 deletions examples/spech-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const app = alexia.createApp('SpeechAssetsExample');
app.customSlot('Mood', ['fine', 'meh']);

app.intent('WhatsUpIntent', 'I am doing {mood:Mood}', (slots, attrs) => {
return 'Whatever you say';
return 'Whatever you say';
});

app.intent('AwesomeIntent', 'You are awesome', (slots, attrs) => {
return 'Yes';
return 'Yes';
});

const speechAssets = app.speechAssets();
Expand Down
8 changes: 4 additions & 4 deletions examples/start-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const alexia = require('..');
const app = alexia.createApp('StartEndExample');

app.onStart(() => {
return 'Welcome to this app';
return 'Welcome to this app';
});

app.onEnd(() => {
return 'So long';
return 'So long';
});

app.intent('MySampleIntent', 'whatever', () => {
return 'Hello, I guess';
return 'Hello, I guess';
});

module.exports = app;
module.exports = app;
2 changes: 1 addition & 1 deletion examples/unnamed-intent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const app = alexia.createApp('UnnamedIntentExample');

// You can ommit the intent name to have it automatically generated
app.intent(null, 'Thank you', () => {
return 'You are welcome';
return 'You are welcome';
});

module.exports = app;
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ignore": ["node_modules", "speechAssets", "mySpeechAssetsDirectory"]
"ignore": ["node_modules", "speechAssets", "mySpeechAssetsDirectory"]
}
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,25 @@
},
"dependencies": {
"bases": "^0.2.1",
"debug": "^2.2.0",
"debug": "^2.3.0",
"doctoc": "^1.2.0",
"glob": "^7.1.1",
"lodash": "^4.13.1",
"lodash": "^4.16.6",
"stack-trace": "0.0.9"
},
"devDependencies": {
"chai": "^3.5.0",
"eslint": "^2.13.0",
"hapi": "^13.5.2",
"istanbul": "^0.4.3",
"mocha": "^2.5.3",
"nodemon": "^1.9.2",
"request": "^2.74.0",
"eslint": "^3.9.1",
"eslint-config-standard": "^6.2.1",
"eslint-plugin-promise": "^3.3.1",
"eslint-plugin-standard": "^2.0.1",
"hapi": "^15.2.0",
"istanbul": "^0.4.5",
"mocha": "^3.1.2",
"nodemon": "^1.11.0",
"request": "^2.78.0",
"rimraf": "^2.5.4",
"sinon": "^1.17.5"
"sinon": "^1.17.6"
},
"engines": {
"node": ">=4.2.0"
Expand Down
8 changes: 4 additions & 4 deletions src/alexia.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const createApp = require('./create-app');
const createRequest = require('./create-request');

module.exports = {
createApp: createApp,
createLaunchRequest: createRequest.launchRequest,
createSessionEndedRequest: createRequest.sessionEndedRequest,
createIntentRequest: createRequest.intentRequest,
createApp: createApp,
createLaunchRequest: createRequest.launchRequest,
createSessionEndedRequest: createRequest.sessionEndedRequest,
createIntentRequest: createRequest.intentRequest
};
Loading

0 comments on commit b25702f

Please sign in to comment.