diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/.metalint/eslint.json b/.metalint/eslint.json new file mode 100644 index 0000000..d284774 --- /dev/null +++ b/.metalint/eslint.json @@ -0,0 +1,267 @@ +{ + "env": { + "amd": true, + "browser": true, + "node": true + }, + + "rules": { + "no-cond-assign": 2, + "no-console": 2, + "no-constant-condition": 2, + "no-control-regex": 2, + "no-debugger": 2, + "no-dupe-args": 2, + "no-dupe-keys": 2, + "no-duplicate-case": 2, + "no-empty-character-class": 2, + "no-empty": 2, + "no-ex-assign": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": [2, { "nestedBinaryExpressions": false }], + "no-extra-semi": 2, + "no-func-assign": 2, + "no-inner-declarations": 2, + "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, + "no-obj-calls": 2, + "no-prototype-builtins": 2, + "no-regex-spaces": 2, + "no-sparse-arrays": 2, + "no-template-curly-in-string": 2, + "no-unexpected-multiline": 2, + "no-unreachable": 2, + "no-unsafe-finally": 2, + "no-unsafe-negation": 2, + "use-isnan": 2, + "valid-jsdoc": [2, { + "prefer": { + "returns": "return", + "class": "constructor" + }, + "requireReturn": false + }], + "valid-typeof": 2, + + "accessor-pairs": 2, + "array-callback-return": 2, + "block-scoped-var": 2, + "class-methods-use-this": 0, + "complexity": 1, + "consistent-return": 2, + "curly": 2, + "default-case": 0, + "dot-location": [2, "property"], + "dot-notation": [2, { "allowKeywords": true, + "allowPattern": "^[a-z]+(_[a-z]+)+$" }], + "eqeqeq": 2, + "guard-for-in": 0, + "no-alert": 2, + "no-caller": 2, + "no-case-declarations": 2, + "no-div-regex": 2, + "no-else-return": 2, + "no-empty-function": 2, + "no-empty-pattern": 2, + "no-eq-null": 0, + "no-eval": 2, + "no-extend-native": 2, + "no-extra-bind": 2, + "no-extra-label": 2, + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-global-assign": 2, + "no-implicit-coercion": 2, + "no-implicit-globals": 2, + "no-implied-eval": 2, + "no-invalid-this": 2, + "no-iterator": 2, + "no-labels": 2, + "no-lone-blocks": 2, + "no-loop-func": 1, + "no-magic-numbers": 0, + "no-multi-spaces": 0, + "no-multi-str": 2, + "no-new-func": 2, + "no-new-wrappers": 2, + "no-new": 2, + "no-octal-escape": 2, + "no-octal": 2, + "no-param-reassign": 0, + "no-proto": 2, + "no-redeclare": 2, + "no-return-assign": 2, + "no-script-url": 2, + "no-self-assign": 2, + "no-self-compare": 2, + "no-sequences": 2, + "no-throw-literal": 2, + "no-unmodified-loop-condition": 2, + "no-unused-expressions": 2, + "no-unused-labels": 0, + "no-useless-call": 2, + "no-useless-concat": 2, + "no-useless-escape": 2, + "no-void": 2, + "no-warning-comments": 1, + "no-with": 2, + "radix": 2, + "vars-on-top": 0, + "wrap-iife": 0, + "yoda": [2, "always"], + + "strict": [2, "function"], + + "init-declarations": 0, + "no-catch-shadow": 2, + "no-delete-var": 2, + "no-label-var": 0, + "no-restricted-globals": 0, + "no-shadow-restricted-names": 2, + "no-shadow": 0, + "no-undef": 2, + "no-undefined": 0, + "no-unused-vars": 2, + "no-use-before-define": 2, + + "callback-return": 0, + "global-require": 0, + "handle-callback-err": 2, + "no-mixed-requires": 2, + "no-new-require": 2, + "no-path-concat": 2, + "no-process-env": 2, + "no-process-exit": 0, + "no-restricted-modules": 0, + "no-restricted-properties": 0, + "no-sync": 0, + + "array-bracket-spacing": 2, + "block-spacing": 2, + "brace-style": 2, + "camelcase": 2, + "comma-dangle": 2, + "comma-spacing": 2, + "comma-style": 2, + "computed-property-spacing": 2, + "consistent-this": 2, + "eol-last": 2, + "func-call-spacing": [2, "never"], + "func-names": 0, + "func-style": 2, + "id-blackkist": 0, + "id-length": 0, + "id-match": 0, + "indent": 0, + "jsx-quotes": 0, + "key-spacing": [2, { "mode": "minimum", "align": "value" }], + "keyword-spacing": 2, + "line-comment-position": 0, + "linebreak-style": 2, + "lines-around-comment": 2, + "lines-around-directive": [2, { "after": "always" }], + "max-depth": [1, { "max": 5 }], + "max-len": 1, + "max-lines": [1, { "skipBlankLines": true, "skipComments": true }], + "max-nested-callbacks": 1, + "max-params": [1, { "max": 5 }], + "max-statements-per-line": [2, { "max": 2 }], + "max-statements": [1, { "max": 30 }], + "multiline-ternary": 0, + "new-cap": 2, + "new-parens": 2, + "newline-after-var": 0, + "newline-before-return": 0, + "newline-per-chained-call": 0, + "no-array-constructor": 2, + "no-bitwise": 2, + "no-continue": 0, + "no-inline-comments": 0, + "no-lonely-if": 2, + "no-mixed-operators": 0, + "no-mixed-spaces-and-tabs": 2, + "no-multiple-empty-lines": 2, + "no-negated-condition": 2, + "no-nested-ternary": 2, + "no-new-object": 2, + "no-plusplus": [2, { "allowForLoopAfterthoughts": true }], + "no-restricted-syntax": [2, [ + "EmptyStatement", "FunctionDeclaration", "LabeledStatement", + "MetaProperty", "Program", "TemplateElement", + "TemplateLiteral", "UpdateExpression", "WithStatement", + "JSXIdentifier", "JSXNamespacedName", "JSXMemberExpression", + "JSXEmptyExpression", "JSXExpressionContainer", "JSXElement", + "JSXClosingElement", "JSXOpeningElement", "JSXAttribute", + "JSXSpreadAttribute", "JSXText" + ]], + "no-tabs": 2, + "no-ternary": 0, + "no-trailing-spaces": 2, + "no-underscore-dangle": 2, + "no-unneeded-ternary": 2, + "no-whitespace-before-property": 2, + "object-curly-newline": 0, + "object-curly-spacing": [2, "always"], + "object-property-newline": [2, { + "allowMultiplePropertiesPerLine": true + }], + "one-var-declaration-per-line": 2, + "one-var": 0, + "operator-assignment": 2, + "operator-linebreak": 2, + "padded-blocks": [2, "never"], + "quote-props": 2, + "quotes": 2, + "require-jsdoc": [2, { + "require": { + "FunctionDeclaration": false, + "MethodDefinition": true, + "ClassDeclaration": true + } + }], + "semi-spacing": 2, + "semi": 2, + "sort-keys": 0, + "sort-vars": 0, + "space-before-blocks": 2, + "space-before-function-paren": 2, + "space-in-parens": 2, + "space-infix-ops": 2, + "space-unary-ops": 2, + "spaced-comment": 2, + "unicode-bom": 2, + "wrap-regex": 2, + + "arrow-body-style": 2, + "arrow-parens": 2, + "arrow-spacing": 2, + "constructor-super": 2, + "generator-star-spacing": 2, + "no-class-assign": 2, + "no-confusing-arrow": 2, + "no-const-assign": 2, + "no-dupe-class-members": 2, + "no-duplicate-imports": 2, + "no-new-symbol": 2, + "no-restricted-imports": 2, + "no-this-before-super": 2, + "no-useless-computed-key": 2, + "no-useless-constructor": 2, + "no-useless-rename": 2, + "no-var": 0, + "object-shorthand": 0, + "prefer-arrow-callback": 0, + "prefer-const": 2, + "prefer-numeric-literals": 2, + "prefer-reflect": 0, + "prefer-rest-params": 0, + "prefer-spread": 2, + "prefer-template": 0, + "require-yield": 2, + "rest-spread-spacing": 2, + "sort-imports": 0, + "symbol-description": 2, + "template-curly-spacing": 2, + "yield-star-spacing": 2 + } +} diff --git a/.metalint/jscs.json b/.metalint/jscs.json deleted file mode 100644 index 1cbcf89..0000000 --- a/.metalint/jscs.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "disallowDanglingUnderscores": true, - "disallowEmptyBlocks": true, - "disallowFunctionDeclarations": true, - "disallowImplicitTypeConversion": [ - "numeric", "boolean", "binary", "string" - ], - "disallowKeywordsInComments": true, - "disallowKeywordsOnNewLine": ["else", "catch"], - "disallowKeywords": ["with"], - "disallowMixedSpacesAndTabs": true, - "disallowMultipleLineStrings": true, - "disallowMultipleVarDecl": true, - "disallowNamedUnassignedFunctions": true, - "disallowNewlineBeforeBlockStatements": true, - "disallowSpaceAfterObjectKeys": true, - "disallowSpaceAfterPrefixUnaryOperators": [ - "++", "--", "+", "-", "~", "!" - ], - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "disallowSpacesInFunctionDeclaration": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInsideArrayBrackets": true, - "disallowSpacesInsideBrackets": true, - "disallowSpacesInsideParentheses": true, - "disallowTrailingComma": true, - "disallowTrailingWhitespace": true, - "maximumLineLength": 80, - "requireAnonymousFunctions": true, - "requireBlocksOnNewline": true, - "requireCamelCaseOrUpperCaseIdentifiers": true, - "requireCapitalizedConstructors": true, - "requireCommaBeforeLineBreak": true, - "requireCurlyBraces": [ - "if", "else", "for", "while", "do", "try", "catch" - ], - "requireDollarBeforejQueryAssignment": true, - "requireDotNotation": "except_snake_case", - "requireLineBreakAfterVariableAssignment": true, - "requireLineFeedAtFileEnd": true, - "requireOperatorBeforeLineBreak": [ - "?", "=", "+", "-", "/", "*", "==", "===", "!=", "!==", ">", ">=", - "<", "<=" - ], - "requirePaddingNewLinesAfterUseStrict": true, - "requireQuotedKeysInObjects": true, - "requireSemicolons": true, - "requireSpaceAfterBinaryOperators": [ - "=", ",", "+", "-", "/", "*", "==", "===", "!=", "!==" - ], - "requireSpaceAfterKeywords": [ - "do", "for", "if", "else", "switch", "case", "try", "catch", "void", - "while", "with", "return", "typeof", "function" - ], - "requireSpaceAfterLineComment": true, - "requireSpaceBeforeBinaryOperators": [ - "=", "+", "-", "/", "*", "==", "===", "!=", "!==" - ], - "requireSpaceBeforeBlockStatements": 1, - "requireSpaceBeforeKeywords": ["else", "while", "catch"], - "requireSpaceBeforeObjectValues": true, - "requireSpaceBetweenArguments": true, - "requireSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInConditionalExpression": true, - "requireSpacesInForStatement": true, - "requireSpacesInFunction": { - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInNamedFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "requireSpacesInsideObjectBrackets": "all", - "requireYodaConditions": true, - "validateIndentation": 4, - "validateLineBreaks": "LF", - "validateParameterSeparator": ", ", - "validateQuoteMarks": "\"" -} diff --git a/.metalint/jshint.json b/.metalint/jshint.json deleted file mode 100644 index 52e1336..0000000 --- a/.metalint/jshint.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "eqeqeq": true, - "freeze": true, - "futurehostile": true, - "latedef": true, - "noarg": true, - "nocomma": true, - "nonbsp": true, - "nonew": true, - "undef": true, - "unused": true -} diff --git a/.metalint/metalint.json b/.metalint/metalint.json index 856a1e3..d3426ad 100644 --- a/.metalint/metalint.json +++ b/.metalint/metalint.json @@ -1,10 +1,11 @@ { - "patterns": ["**", "!.git/**"], + "patterns": ["!.git/**", "!node_modules/**", "**"], "hidden": true, + "verbose": 2, "checkers": [ { - "patterns": ["**/*.js", "!**/*.min.js"], - "linters": ["jscs", "jshint"] + "patterns": ["!**/*.min.js", "**/*.js"], + "linters": "eslint" }, { "patterns": "**/*.md", "linters": "markdownlint" diff --git a/bower.json b/bower.json index 7c35996..165e443 100644 --- a/bower.json +++ b/bower.json @@ -2,10 +2,12 @@ "name": "scronpt", "description": "Bibliothèque JavaScript implémentant un programme Unix cron.", - "version": "0.3.0", + "version": "0.3.1", "main": "scronpt.js", "license": "Licence Public Rien À Branler", - "ignore": [".git", ".metalint", "package.json"], + "ignore": [ + ".git", ".gitignore", ".metalint", "node_modules", "package.json" + ], "keywords": [ "scronpt", "javascript", "js", "cron", "crontab", "scheduler" ], diff --git a/package.json b/package.json index e76719a..34785be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scronpt", - "version": "0.3.0", + "version": "0.3.1", "description": "Bibliothèque JavaScript implémentant un programme Unix cron.", "keywords": [ @@ -26,6 +26,9 @@ }, "dependencies": {}, "devDependencies": { - "metalint": "^0.1.0" + "eslint": "^3.5.0", + "jsonlint": "^1.6.2", + "markdownlint": "^0.2.0", + "metalint": "^0.7.0" } } diff --git a/scronpt.js b/scronpt.js index 4eb4228..276355e 100644 --- a/scronpt.js +++ b/scronpt.js @@ -1,5 +1,3 @@ -/* global setInterval, clearInterval, setTimeout, define, module */ - /** * Bibliothèque JavaScript Scronpt implémentant un programme Unix cron. * @@ -119,7 +117,7 @@ // Parcourir les cinq champs. return fields.map(function (field, i) { // Gérer les notations avec un astérisque ("*" ou "*/x"). - var result = /^\*(?:\/(\d+))?$/.exec(field); + var result = (/^\*(?:\/(\d+))?$/).exec(field); if (null !== result) { if (undefined === result[1]) { // "*". return null; @@ -150,7 +148,7 @@ // Gérer les listes. return field.split(",").map(function (range) { - var result = /^(\d+)(?:-(\d+)(?:\/(\d+))?)?$/.exec(range); + var result = (/^(\d+)(?:-(\d+)(?:\/(\d+))?)?$/).exec(range); if (null === result) { throw new Error(ERROR + input); } @@ -255,8 +253,7 @@ * @param {!function()} func - la fonction appelée quand la tâche est * exécutée. * @param {...*} args - les paramètres qui seront passés à la - fonction. - * @return {!Object} Retourne la tâche créée. + * fonction. * @throws {Error} Si la syntaxe de la notation cron est incorrecte. * @throws {RangeError} Si un intervalle est invalide (hors limite ou la * borne supérieure est plus grande que la borne diff --git a/scronpt.min.js b/scronpt.min.js index 1228d71..c6ba4a7 100644 --- a/scronpt.min.js +++ b/scronpt.min.js @@ -1,4 +1,4 @@ -//Scronpt 0.3.0|regseb.github.io/scronpt +//Scronpt 0.3.1|regseb.github.io/scronpt (function(h,f){"function"===typeof define&&define.amd?define([],f):"object"===typeof exports?module.exports=f():h.Cron=f()})(this,function(){var h=[[],[],[]," jan feb mar apr may jun jul aug sep oct nov dec".split(" "),"sun mon tue wed thu fri sat".split(" ")],f=[{min:0,max:59},{min:0,max:23},{min:1,max:31},{min:1,max:12},{min:0,max:7}],e=[],k=-1,l=function(b){switch(b){case "@yearly":case "@annually":b="0 0 1 1 *";break;case "@monthly":b="0 0 1 * *";break;case "@weekly":b="0 0 * * 0";break;case "@daily":case "@midnight":b= "0 0 * * *";break;case "@hourly":b="0 * * * *"}var a=b.split(/\s+/);if(5!==a.length)throw Error("Syntax error, unrecognized expression: "+b);return a.map(function(a,d){var c=/^\*(?:\/(\d+))?$/.exec(a);if(null!==c){if(void 0===c[1])return null;c=parseInt(c[1],10);if(0===c)throw new RangeError("Syntax error, unrecognized expression: "+b);return[{min:0,max:Infinity,step:c}]}c=h[d].indexOf(a.toLowerCase());return-1!==c?[{min:c,max:c,step:1}]:a.split(",").map(function(a){var c=/^(\d+)(?:-(\d+)(?:\/(\d+))?)?$/.exec(a); if(null===c)throw Error("Syntax error, unrecognized expression: "+b);a=parseInt(c[1],10);var e=parseInt(c[2],10),c=parseInt(c[3],10);if(a