diff --git a/README.md b/README.md index f52c989..9453df3 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ JavaScript Standard Style with custom PON tweaks +The default standardjs lint rules: https://github.com/standard/eslint-config-standard/blob/master/.eslintrc.json + ## Install ``` diff --git a/bin/cmd.js b/bin/cmd.js index 11c5f9d..da723de 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -6,11 +6,11 @@ var major = parseInt(match[1], 10) var minor = parseInt(match[2], 10) if (major >= 14 || (major === 14 && minor >= 14)) { - eval('import("standard-engine")').then(function (standardEngine) { - eval('import("../options.js")').then(function (options) { - standardEngine.cli(options.default) - }) + eval('import("standard-engine")').then((standardEngine) => { + eval('import("../options.js")').then((options) => { + standardEngine.cli(options.default) }) + }) } else { - console.error('ponstandard: Node 14.14.0 or greater is required. `pomstandard` did not run.') + console.error('ponstandard: Node 14.14.0 or greater is required. `pomstandard` did not run.') } diff --git a/eslintrc.json b/eslintrc.json index 6364538..c2d1d10 100644 --- a/eslintrc.json +++ b/eslintrc.json @@ -1,20 +1,17 @@ { "extends": "standard", "rules": { - "indent": [ + "block-scoped-var": "error", + "complexity": [ "error", - 4, { - "ignoredNodes": [ - "TemplateLiteral" - ] + "max": 20 } ], - "camelcase": [ + "consistent-return": "error", + "max-classes-per-file": [ "error", - { - "properties": "never" - } + 1 ], "max-params": [ "warn", @@ -33,59 +30,66 @@ "unix" ], "class-methods-use-this": "off", - "comma-style": [ - "warn", - "last" - ], - "no-mixed-spaces-and-tabs": [ - "warn" - ], - "no-prototype-builtins": "off", - "no-return-assign": [ + "no-alert": "error", + "no-caller": "error", + "no-extra-label": "error", + "no-labels": [ "error", - "except-parens" + { + "allowLoop": false, + "allowSwitch": false + } ], + "no-loop-func": "error", + "no-prototype-builtins": "off", "no-restricted-syntax": [ "error", "ForInStatement", "LabeledStatement", "WithStatement" ], - "no-unused-vars": [ + "no-return-await": "error", + "no-else-return": [ "error", { - "ignoreRestSiblings": true, - "argsIgnorePattern": "res|next|^err" + "allowElseIf": false } ], - "prefer-const": [ - "error", - { - "destructuring": "all" - } + "no-multi-assign": [ + "error" ], "arrow-body-style": [ "error", "as-needed" ], - "no-unused-expressions": [ - "error", - { - "allowTaggedTemplates": true - } - ], + "no-console": "warn", "no-param-reassign": [ "error", { - "props": false + "props": true, + "ignorePropertyModificationsFor": [ + "acc", + "accumulator", + "e", + "req", + "request", + "res", + "response" + ] } ], + "no-useless-concat": "error", + "no-nested-ternary": "error", "max-len": [ "error", { "code": 120, "comments": 80, - "tabWidth": 4 + "tabWidth": 4, + "ignoreUrls": true, + "ignoreRegExpLiterals": true, + "ignoreStrings": true, + "ignoreTemplateLiterals": true } ], "no-shadow": [ @@ -102,6 +106,16 @@ ] } ], + "no-spaced-func": "error", + "no-underscore-dangle": [ + "error", + { + "allow": [], + "allowAfterThis": false, + "allowAfterSuper": false, + "enforceInMethodNames": true + } + ], "quotes": [ "error", "single", @@ -110,8 +124,110 @@ "allowTemplateLiterals": true } ], + "radix": "error", "import/prefer-default-export": "off", + "import/no-unresolved": [ + "error", + { + "caseSensitive": true + } + ], + "import/named": "error", + "import/no-named-as-default": "error", + "import/no-named-as-default-member": "error", + "import/no-mutable-exports": "error", + "import/order": [ + "error", + { + "groups": [ + [ + "builtin", + "external", + "internal" + ] + ] + } + ], + "import/newline-after-import": "error", + "import/no-self-import": "error", + "import/no-cycle": [ + "error", + { + "maxDepth": "∞" + } + ], + "import/no-useless-path-segments": [ + "error", + { + "commonjs": true + } + ], "vars-on-top": "error", + "for-direction": "error", + "getter-return": [ + "error", + { + "allowImplicit": true + } + ], + "no-await-in-loop": "error", + "no-inner-declarations": "error", + "no-var": "error", + "no-lonely-if": "error", + "prefer-arrow-callback": [ + "error", + { + "allowNamedFunctions": false, + "allowUnboundThis": true + } + ], + "prefer-destructuring": [ + "error", + { + "VariableDeclarator": { + "array": false, + "object": true + }, + "AssignmentExpression": { + "array": true, + "object": false + } + }, + { + "enforceForRenamedProperties": false + } + ], + "prefer-rest-params": "error", + "prefer-spread": "error", + "prefer-template": "error", + "require-yield": "error", + "function-paren-newline": [ + "error", + "consistent" + ], + "implicit-arrow-linebreak": [ + "error", + "beside" + ], + "newline-per-chained-call": [ + "error", + { + "ignoreChainWithDepth": 4 + } + ], + "nonblock-statement-body-position": [ + "error", + "beside", + { + "overrides": {} + } + ], + "operator-assignment": [ + "error", + "always" + ], + "prefer-object-spread": "error", + "no-delete-var": "error", "valid-jsdoc": [ "error", { diff --git a/options.js b/options.js index e0861a7..13df8ee 100644 --- a/options.js +++ b/options.js @@ -9,16 +9,17 @@ const pkg = JSON.parse(readFileSync(pkgUrl, 'utf-8')) const configFile = fileURLToPath(new URL('eslintrc.json', import.meta.url)) const baseConfig = JSON.parse(readFileSync(stdOpts.eslintConfig.configFile, 'utf-8')) -export default Object.assign({}, stdOpts, { - bugs: pkg.bugs.url, - cmd: 'ponstandard', - eslint, - eslintConfig: { - baseConfig, - configFile, - useEslintrc: true - }, - homepage: pkg.homepage, - tagline: 'Use JavaScript Standard Style (tweaked by PON)', - version: `${pkg.version} (standard ${stdVersion})` +export default ({ + ...stdOpts, + bugs: pkg.bugs.url, + cmd: 'ponstandard', + eslint, + eslintConfig: { + baseConfig, + configFile, + useEslintrc: true + }, + homepage: pkg.homepage, + tagline: 'Use JavaScript Standard Style (tweaked by PON)', + version: `${pkg.version} (standard ${stdVersion})` }) diff --git a/package-lock.json b/package-lock.json index d1054dc..1db27b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ponbike/ponstandard", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@ponbike/ponstandard", - "version": "0.1.0", + "version": "0.2.0", "license": "GPL-3", "dependencies": { "eslint": "^7.32.0", diff --git a/package.json b/package.json index f044743..fbbcb20 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ponbike/ponstandard", "description": "JavaScript Standard Style with custom PON tweaks", - "version": "0.1.0", + "version": "0.2.0", "author": { "name": "Pieter Wigboldus", "email": "pieter.wigboldus@pon.com",