Skip to content

Commit

Permalink
Add Travis support (#23)
Browse files Browse the repository at this point in the history
See #13, #19.
  • Loading branch information
pento authored Jul 31, 2017
1 parent 421e748 commit f51c4be
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
14 changes: 2 additions & 12 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@
"browser": true,
"mocha": true
},
"extends": "airbnb/base",
"extends": "wpcalypso/react",
"parser": "babel-eslint",
"rules": {
"comma-dangle": 0,
"import/prefer-default-export": 0,

"no-underscore-dangle": 0,
"yoda": 0,
"prefer-rest-params": 0
},
"settings": {
"import/resolver": {
"babel-module": {}
}
"max-len": [ 2, { code: 140 } ]
}
}
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- "node"

cache:
directories:
- "node_modules"

script: npm run travis
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"start": "mkdir -p ./build/dev && webpack --config ./webpack/webpack.config.dev.js",
"lint": "eslint src/js/",
"test": "mocha-webpack --watch --webpack-config ./webpack/webpack.config.test.js \"src/js/**/*.spec.js\"",
"test:ci": "mocha-webpack --webpack-config ./webpack/webpack.config.test.js \"src/js/**/*.spec.js\""
"test:ci": "mocha-webpack --webpack-config ./webpack/webpack.config.test.js \"src/js/**/*.spec.js\"",
"travis": "npm run lint && npm run test:ci"
},
"dependencies": {
},
Expand All @@ -27,9 +28,10 @@
"crx-webpack-plugin": "0.1.5",
"css-loader": "0.26.0",
"eslint": "3.14.0",
"eslint-config-airbnb": "14.0.0",
"eslint-import-resolver-babel-module": "2.2.1",
"eslint-plugin-import": "2.2.0",
"eslint-config-wpcalypso": "0.8.0",
"eslint-eslines": "0.0.3",
"eslint-plugin-react": "6.4.1",
"eslint-plugin-wpcalypso": "3.3.0",
"eventemitter2": "0.4.14",
"mocha": "1.20.0",
"mocha-webpack": "0.7.0",
Expand Down
39 changes: 21 additions & 18 deletions src/js/content.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var shiftPressed = false;
let shiftPressed = false;

function pasteHandler( e ) {
if ( shiftPressed ) {
Expand All @@ -9,7 +9,7 @@ function pasteHandler( e ) {
return;
}

var pasted = e.clipboardData.getData( 'text/plain' );
const pasted = e.clipboardData.getData( 'text/plain' );
if ( '' === pasted ) {
return;
}
Expand All @@ -18,7 +18,7 @@ function pasteHandler( e ) {
return;
}

var editor = e.target;
const editor = e.target;

if ( ! editor ) {
return;
Expand All @@ -35,14 +35,14 @@ function pasteHandler( e ) {
return;
}

var inputTypeAllowed = false;
let inputTypeAllowed = false;

if ( 'TEXTAREA' === editor.nodeName ) {
inputTypeAllowed = true;
}

// Normally we don't want to do this on <input> tags, but there are exceptions.
var inputElementSites = [
const inputElementSites = [
'teuxdeux.com'
];

Expand All @@ -54,7 +54,7 @@ function pasteHandler( e ) {
return;
}

var start, end;
let start, end;

if ( editor.selectionStart > editor.selectionEnd ) {
start = editor.selectionEnd;
Expand All @@ -69,20 +69,23 @@ function pasteHandler( e ) {
return;
}

var markdownSites = [
const markdownSites = [
'hackerone.com',
'github.com',
'reddit.com',
'teuxdeux.com'
];

var bbCodeEl = document.getElementById( 'disable_bbcode' );
let bbCodeEl = document.getElementById( 'disable_bbcode' );
if ( ! bbCodeEl ) {
bbCodeEl = document.getElementsByClassName( 'show_bbcode' ).item( 0 );
}

var tracForm = document.getElementById( 'propertyform' );
if( tracForm && ( tracForm.getAttribute( 'action' ).indexOf( '/newticket' ) >= 0 || tracForm.getAttribute( 'action' ).indexOf( '/ticket/' ) >= 0 ) ) {
const tracForm = document.getElementById( 'propertyform' );
if ( tracForm &&
( tracForm.getAttribute( 'action' ).indexOf( '/newticket' ) >= 0 ||
tracForm.getAttribute( 'action' ).indexOf( '/ticket/' ) >= 0 )
) {
pasteTrac( e, editor, pasted, start, end );
} else if ( markdownSites.find( domainCheck ) ) {
pasteMarkdown( e, editor, pasted, start, end );
Expand All @@ -103,7 +106,7 @@ function pasteTrac( e, editor, pasted, start, end ) {
e.preventDefault();
document.execCommand( 'insertText', false, '[' + pasted + ' ' + editor.value.slice( start, end ) + ']' );

var newPos;
let newPos;

if ( start === end ) {
newPos = start + pasted.length + 2;
Expand All @@ -118,7 +121,7 @@ function pasteMarkdown( e, editor, pasted, start, end ) {
e.preventDefault();
document.execCommand( 'insertText', false, '[' + editor.value.slice( start, end ) + '](' + pasted + ')' );

var newPos;
let newPos;

if ( start === end ) {
newPos = start + 1;
Expand All @@ -133,7 +136,7 @@ function pasteBBcode( e, editor, pasted, start, end ) {
e.preventDefault();
document.execCommand( 'insertText', false, '[url=' + pasted + ']' + editor.value.slice( start, end ) + '[/url]' );

var newPos;
let newPos;

if ( start === end ) {
newPos = start + pasted.length + 6;
Expand All @@ -148,7 +151,7 @@ function pasteRemarkup( e, editor, pasted, start, end ) {
e.preventDefault();
document.execCommand( 'insertText', false, '[[ ' + pasted + ' | ' + editor.value.slice( start, end ) + ' ]]' );

var newPos;
let newPos;

if ( start === end ) {
newPos = start + pasted.length + 6;
Expand All @@ -161,7 +164,7 @@ function pasteRemarkup( e, editor, pasted, start, end ) {

function pasteHTML( e, editor, pasted, start, end ) {
// Make sure we are not in a tag first
var leftString = editor.value.slice( 0, start ).toLowerCase();
const leftString = editor.value.slice( 0, start ).toLowerCase();

// If we are inside a (start) tag for any HTML element, its not ok to paste as a an a-href
if ( ( -1 < leftString.lastIndexOf( '<' ) ) && ( leftString.lastIndexOf( '<' ) > leftString.lastIndexOf( '>' ) ) ) {
Expand All @@ -177,7 +180,7 @@ function pasteHTML( e, editor, pasted, start, end ) {
e.preventDefault();
document.execCommand( 'insertText', false, '<a href="' + pasted + '">' + editor.value.slice( start, end ) + '</a>' );

var newPos;
let newPos;

if ( start === end ) {
newPos = start + pasted.length + 11;
Expand All @@ -193,9 +196,9 @@ function domainCheck( site ) {
}

// Don't bother attaching the paste event if we're on a site we don't want to run on.
var attach = true;
let attach = true;

var blockedSites = [
const blockedSites = [
'gist.github.com',
'facebook.com',
'slack.com',
Expand Down

0 comments on commit f51c4be

Please sign in to comment.