diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..889b20a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +# For more information about the properties used in +# this file, please see the EditorConfig documentation: +# http://editorconfig.org/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..0be8323 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,16 @@ +env: + node: true +rules: + indent: [2, 2] + linebreak-style: 2 + no-irregular-whitespace: 2 + no-trailing-spaces: 2 + quotes: [2, "single", "avoid-escape"] + + # Relax rules to allow current code-style + curly: [2, "multi"] + new-cap: 0 + no-shadow: 0 + no-unused-vars: 0 + no-use-before-define: 0 + strict: 0 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..cf911c1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Automatically normalize line endings for all text-based files +# http://git-scm.com/docs/gitattributes#_end_of_line_conversion +* text=auto + +# For the following file types, normalize line endings to LF on +# checkin and prevent conversion to CRLF when they are checked out +# (this is required in order to prevent newline related issues like, +# for example, after the build script is run) +.* text eol=lf +*.css text eol=lf +*.html text eol=lf +*.js text eol=lf +*.json text eol=lf +*.md text eol=lf +*.sh text eol=lf +*.txt text eol=lf +*.xml text eol=lf diff --git a/Makefile b/Makefile index 71825bd..b8ff528 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ +eslint=node_modules/.bin/eslint lib/index.js test/index.js +mocha=node_modules/.bin/mocha --reporter spec --harmony-generators node_modules: package.json @npm install test: node_modules - @./node_modules/.bin/mocha --reporter spec --harmony-generators + @$(mocha) + @$(eslint) -.PHONY: test \ No newline at end of file +.PHONY: test diff --git a/lib/index.js b/lib/index.js index 5b0754e..26a8a45 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,3 @@ - var consolidate = require('consolidate'); var debug = require('debug')('metalsmith-layouts'); var each = require('async').each; @@ -31,7 +30,7 @@ var settings = ['engine', 'directory', 'pattern', 'default']; function plugin(opts){ opts = opts || {}; - if ('string' == typeof opts) opts = { engine: opts }; + if (typeof opts === 'string') opts = { engine: opts }; if (!opts.engine) throw new Error('"engine" option required'); var engine = opts.engine; diff --git a/package.json b/package.json index 045e136..23b384f 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ }, "devDependencies": { "assert-dir-equal": "^1.0.1", + "eslint": "^0.24.1", "metalsmith": "^2.0.1", "mocha": "^2.2.5", "swig": "^1.4.2" diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 0000000..a174f9b --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,3 @@ +extends: ../.eslintrc +env: + mocha: true diff --git a/test/index.js b/test/index.js index 029e8fc..faa756e 100644 --- a/test/index.js +++ b/test/index.js @@ -1,4 +1,3 @@ - var assert = require('assert'); var equal = require('assert-dir-equal'); var Metalsmith = require('metalsmith'); @@ -75,4 +74,4 @@ describe('metalsmith-layouts', function(){ done(); }); }); -}); \ No newline at end of file +});