Commit f9b298bd authored by Ashur Cabrera's avatar Ashur Cabrera
Browse files

Initial commit

parents
module.exports = {
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
}
};
\ No newline at end of file
node_modules
# Whitespace
Whitespace cleanup for Nova.
{
"identifier": "cab.ashur.Whitespace",
"name": "Whitespace",
"author": "Ashur Cabrera",
"description": "Whitespace cleanup",
"version": "1.0",
"main": "main.js",
"entitlements": {},
"commands": {}
}
/**
* Trim trailing whitespace from string
*
* @param string
* @return string
*/
module.exports.trimEnd = string => string.trimEnd();
/**
* Ensure final character is a newline
*
* @param string
* @return string
*/
module.exports.ensureFinalNewline = (char, eol) =>
{
let result;
if( char !== eol )
{
result = `${char}${eol}`;
}
else
{
result = eol;
}
return result;
};
This diff is collapsed.
{
"name": "nova-whitespace",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "npm run test:lint && npm run test:unit",
"test:lint": "eslint test/**/**.js Whitespace.novaextension/scripts/**.js",
"test:integration": "echo ???",
"test:unit": "mocha test/unit"
},
"author": "",
"license": "ISC",
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^6.1.0",
"mocha": "^6.2.0",
"panic-test": "git+ssh://git@gitlab.panic.com:22222/ashur/panic-test.git"
}
}
const {assert} = require( 'chai' );
const Whitespace = require( '../../Whitespace.novaextension/scripts/whitespace.js' );
const { suite } = require( 'panic-test' );
suite( 'Whitespace', test =>
{
});
/* global describe it */
const {assert} = require( 'chai' );
const Whitespace = require( '../../Whitespace.novaextension/scripts/whitespace.js' );
describe( 'Whitespace', () =>
{
describe( '#trimEnd', () =>
{
it( 'should trim trailing whitespace', () =>
{
assert.equal( Whitespace.trimEnd( 'hello world ' ), 'hello world' );
});
it( 'should not trim leading whitespace', () =>
{
assert.equal( Whitespace.trimEnd( ' hello world' ), ' hello world' );
});
});
const eols = ["\n", "\r", "\r\n"];
describe( '#ensureFinalNewline', () =>
{
it( 'should add EOL if missing', () =>
{
for( let eol of eols )
{
let char = 'd'; // ex., 'hello world' with no final newline
assert.equal(
Whitespace.ensureFinalNewline( char, eol ),
char + eol,
);
}
});
it( 'should not add EOL if already present', () =>
{
for( let eol of eols )
{
let char = eol; // ex., 'hello world\n' with final newline
assert.equal(
Whitespace.ensureFinalNewline( char, eol ),
eol,
);
}
});
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment