From 9ffa06442b0fbcb7814da280e6c68c6b784c5f95 Mon Sep 17 00:00:00 2001 From: Szymon Cofalik Date: Fri, 18 Mar 2016 16:10:06 +0100 Subject: [PATCH] Initial commit. --- .editorconfig | 12 ++++++ .gitattributes | 18 ++++++++ .gitignore | 10 +++++ .jscsrc | 63 ++++++++++++++++++++++++++++ .jshintrc | 14 +++++++ CHANGES.md | 6 +++ CONTRIBUTING.md | 4 ++ LICENSE.md | 23 +++++++++++ README.md | 10 +++++ dev/.jshintrc | 14 +++++++ dev/tasks/lint/tasks.js | 92 +++++++++++++++++++++++++++++++++++++++++ gulpfile.js | 19 +++++++++ package.json | 27 ++++++++++++ tests/.jshintrc | 26 ++++++++++++ 14 files changed, 338 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .jscsrc create mode 100644 .jshintrc create mode 100644 CHANGES.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 dev/.jshintrc create mode 100644 dev/tasks/lint/tasks.js create mode 100644 gulpfile.js create mode 100644 package.json create mode 100644 tests/.jshintrc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..541fc2d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# Configurations to normalize the IDE behavior. +# http://editorconfig.org/ + +root = true + +[*] +indent_style = tab +tab_width = 4 +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9c20d56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,18 @@ +* text=auto + +*.htaccess eol=lf +*.cgi eol=lf +*.sh eol=lf + +*.css text +*.htm text +*.html text +*.js text +*.json text +*.php text +*.txt text +*.md text + +*.png -text +*.gif -text +*.jpg -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a073df --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# These files will be ignored by Git and by our linting tools: +# grunt jshint +# grunt jscs +# +# Be sure to append /** to folders to have everything inside them ignored. + +# All "dot directories". +.*/** + +node_modules/** diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..c1b7467 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,63 @@ +{ + "esnext": true, + + "requireCurlyBraces": [ + "if", "else", "for", "while", "do", "switch", "try", "catch" + ], + "requireSpaceBeforeKeywords": true, + "requireSpaceAfterKeywords": [ + "do", "for", "if", "else", "switch", "case", "try", "catch", "void", "while", "with", "return", "typeof" + ], + "requireSpaceBeforeBlockStatements": true, + "requireParenthesesAroundIIFE": true, + "requireSpacesInConditionalExpression": { + "afterTest": true, + "beforeConsequent": true, + "afterConsequent": true, + "beforeAlternate": true + }, + "requireSpacesInFunction": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInFunction": { + "beforeOpeningRoundBrace": true + }, + "disallowSpacesInCallExpression": true, + "disallowMultipleVarDecl": "exceptUndefined", + "requireBlocksOnNewline": true, + "disallowPaddingNewlinesInBlocks": true, + "requirePaddingNewlinesBeforeKeywords": [ + "do", "for", "if", "switch", "case", "try", "while", "with", "return" + ], + "requireSpacesInsideObjectBrackets": "all", + "requireSpacesInsideArrayBrackets": "all", + "requireSpacesInsideParentheses": "all", + "disallowSpaceAfterObjectKeys": true, + "requireSpaceBeforeObjectValues": true, + "requireCommaBeforeLineBreak": true, + "requireOperatorBeforeLineBreak": true, + "disallowSpaceAfterPrefixUnaryOperators": true, + "disallowSpaceBeforePostfixUnaryOperators": true, + "requireSpaceBeforeBinaryOperators": true, + "disallowImplicitTypeConversion": [ + "numeric", "binary", "string" + ], + "requireCamelCaseOrUpperCaseIdentifiers": true, + "requireSpaceAfterBinaryOperators": true, + "disallowKeywords": [ + "with" + ], + "disallowMultipleLineStrings": true, + "disallowMultipleLineBreaks": true, + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "maximumLineLength": 140, + "requireCapitalizedConstructors": true, + "requireDotNotation": true, + "disallowYodaConditions": true, + "disallowNewlineBeforeBlockStatements": true, + "validateLineBreaks": "LF", + "validateQuoteMarks": "'", + "validateIndentation": "\t", + "safeContextKeyword": [ "that" ] +} \ No newline at end of file diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..79ba73f --- /dev/null +++ b/.jshintrc @@ -0,0 +1,14 @@ +{ + "browser": true, + "esnext": true, + + "immed": true, + "latedef": "nofunc", + "loopfunc": true, + "noarg": true, + "nonbsp": true, + "undef": true, + "unused": true, + "strict": "global", + "varstmt": true +} diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..7d9cb86 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,6 @@ +Undo Feature Changelog +======================================== + +## Undo Feature 0.0.1 + +First release. \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..aefc066 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,4 @@ +Contributing +======================================== + +Information about contributing can be found at the following page: . diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..174d0b4 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,23 @@ +Software License Agreement +========================== + +**Undo Feature** – https://github.com/ckeditor/ckeditor5
+Copyright (c) 2003-2016, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved. + +Licensed under the terms of any of the following licenses at your choice: + +* [GNU General Public License Version 2 or later (the "GPL")](http://www.gnu.org/licenses/gpl.html) +* [GNU Lesser General Public License Version 2.1 or later (the "LGPL")](http://www.gnu.org/licenses/lgpl.html) +* [Mozilla Public License Version 1.1 or later (the "MPL")](http://www.mozilla.org/MPL/MPL-1.1.html) + +You are not required to, but if you want to explicitly declare the license you have chosen to be bound to when using, reproducing, modifying and distributing this software, just include a text file titled "legal.txt" in your version of this software, indicating your license choice. In any case, your choice will not restrict any recipient of your version of this software to use, reproduce, modify and distribute this software under any of the above licenses. + +Sources of Intellectual Property Included in CKEditor +----------------------------------------------------- + +Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission. + +Trademarks +---------- + +**CKEditor** is a trademark of [CKSource](http://cksource.com) Frederico Knabben. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders. diff --git a/README.md b/README.md new file mode 100644 index 0000000..aaa2169 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +Undo Feature +======================================== + +[![devDependency Status](https://david-dm.org/ckeditor/ckeditor5-undo/dev-status.svg)](https://david-dm.org/ckeditor/ckeditor5-undo#info=devDependencies) + +Undo Feature for CKEditor 5 More information about the project can be found at the following url: . + +## License + +Licensed under the GPL, LGPL and MPL licenses, at your choice. For full details about the license, please check the `LICENSE.md` file. diff --git a/dev/.jshintrc b/dev/.jshintrc new file mode 100644 index 0000000..84e1da4 --- /dev/null +++ b/dev/.jshintrc @@ -0,0 +1,14 @@ +{ + "node": true, + "esnext": true, + + "immed": true, + "latedef": "nofunc", + "loopfunc": true, + "noarg": true, + "nonbsp": true, + "undef": true, + "unused": true, + "strict": true, + "varstmt": true +} diff --git a/dev/tasks/lint/tasks.js b/dev/tasks/lint/tasks.js new file mode 100644 index 0000000..d5b688b --- /dev/null +++ b/dev/tasks/lint/tasks.js @@ -0,0 +1,92 @@ +/* jshint node: true, esnext: true */ + +'use strict'; + +const gulp = require( 'gulp' ); +const jshint = require( 'gulp-jshint' ); +const jscs = require( 'gulp-jscs' ); +const fs = require( 'fs' ); +const guppy = require( 'git-guppy' )( gulp ); +const gulpFilter = require( 'gulp-filter' ); +const gutil = require( 'gulp-util' ); + +module.exports = ( config ) => { + const src = [ '**/*.js' ].concat( config.IGNORED_FILES.map( i => '!' + i ), getGitIgnore() ); + + const tasks = { + /** + * Returns stream containing jshint and jscs reporters. + * + * @returns {Stream} + */ + lint() { + return gulp.src( src ) + .pipe( lint() ); + }, + + /** + * This method is executed on pre-commit hook, linting only files staged for current commit. + * + * @returns {Stream} + */ + lintStaged() { + return guppy.stream( 'pre-commit', { base: './' } ) + .pipe( gulpFilter( src ) ) + .pipe( lint() ) + + // Error reporting for gulp. + .pipe( jscs.reporter( 'fail' ) ) + .on( 'error', errorHandler ) + .pipe( jshint.reporter( 'fail' ) ) + .on( 'error', errorHandler ); + + /** + * Handles error from jscs and jshint fail reporters. Stops node process with error code + * and prints error message to the console. + */ + function errorHandler() { + gutil.log( gutil.colors.red( 'Linting failed, commit aborted' ) ); + process.exit( 1 ); + } + } + }; + + gulp.task( 'lint', tasks.lint ); + gulp.task( 'lint-staged', tasks.lintStaged ); + + return tasks; + + /** + * Gets the list of ignores from `.gitignore`. + * + * @returns {String[]} The list of ignores. + */ + function getGitIgnore( ) { + let gitIgnoredFiles = fs.readFileSync( '.gitignore', 'utf8' ); + + return gitIgnoredFiles + // Remove comment lines. + .replace( /^#.*$/gm, '' ) + // Transform into array. + .split( /\n+/ ) + // Remove empty entries. + .filter( ( path ) => !!path ) + // Add `!` for ignore glob. + .map( i => '!' + i ); + } + + /** + * Returns stream with all linting plugins combined. + * + * @returns {Stream} + */ + function lint() { + const stream = jshint(); + stream + .pipe( jscs() ) + .pipe( jscs.reporter() ) + .pipe( jshint.reporter( 'jshint-reporter-jscs' ) ); + + return stream; + } +}; diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..62e017b --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,19 @@ +/* jshint node: true */ + +'use strict'; + +const gulp = require( 'gulp' ); + +const config = { + ROOT_DIR: '.', + WORKSPACE_DIR: '..', + + // Files ignored by jshint and jscs tasks. Files from .gitignore will be added automatically during tasks execution. + IGNORED_FILES: [ + 'src/lib/**' + ] +}; + +require( './dev/tasks/lint/tasks' )( config ); + +gulp.task( 'pre-commit', [ 'lint-staged' ] ); diff --git a/package.json b/package.json new file mode 100644 index 0000000..63636d6 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "ckeditor5-undo", + "version": "0.0.1", + "description": "Undo Feature for CKEditor 5", + "keywords": [], + "dependencies": {}, + "devDependencies": { + "git-guppy": "^1.1.0", + "gulp": "^3.9.0", + "gulp-filter": "^3.0.1", + "gulp-jscs": "^3.0.2", + "gulp-jshint": "^2.0.0", + "gulp-util": "^3.0.7", + "guppy-pre-commit": "^0.3.0", + "jshint": "^2.9.1", + "jshint-reporter-jscs": "^0.1.0" + }, + "engines": { + "node": ">=5.0.0", + "npm": ">=3.0.0" + }, + "author": "CKSource (http://cksource.com/)", + "license": "See LICENSE.md", + "homepage": "", + "bugs": "", + "repository": "" +} diff --git a/tests/.jshintrc b/tests/.jshintrc new file mode 100644 index 0000000..570426b --- /dev/null +++ b/tests/.jshintrc @@ -0,0 +1,26 @@ +{ + "browser": true, + "esnext": true, + + "expr": true, + "immed": true, + "latedef": "nofunc", + "loopfunc": true, + "noarg": true, + "nonbsp": true, + "strict": "global", + "undef": true, + "unused": true, + "varstmt": true, + + "globals": { + "after": false, + "afterEach": false, + "before": false, + "beforeEach": false, + "describe": false, + "expect": false, + "it": false, + "sinon": false + } +}