From 818af3b5e156aa98227f8ac5fb9bbebb1aba4151 Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Tue, 11 Jul 2023 12:53:07 -0400 Subject: [PATCH] Build: use JS for eslint config - this makes it easier to use this config in esm eslint.config.js --- .eslintrc.js | 6 ++ .eslintrc.json | 153 ------------------------------------- index.js | 104 +++++++++++++++++++++++++ package.json | 4 +- test/fixtures/.eslintrc | 16 ---- test/fixtures/.eslintrc.js | 21 +++++ 6 files changed, 133 insertions(+), 171 deletions(-) create mode 100644 .eslintrc.js delete mode 100644 .eslintrc.json create mode 100644 index.js delete mode 100644 test/fixtures/.eslintrc create mode 100644 test/fixtures/.eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..09be150 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + extends: "./index.js", + env: { + node: true + } +}; diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index cccdadf..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,153 +0,0 @@ -{ - "rules": { - "no-negated-in-lhs": "error", - "no-cond-assign": [ - "error", - "except-parens" - ], - "curly": [ - "error", - "all" - ], - "object-curly-spacing": [ - "error", - "always" - ], - "computed-property-spacing": [ - "error", - "always" - ], - "array-bracket-spacing": [ - "error", - "always" - ], - "eqeqeq": [ - "error", - "smart" - ], - "no-unused-expressions": "error", - "no-sequences": "error", - "no-nested-ternary": "error", - "no-unreachable": "error", - "wrap-iife": [ - "error", - "inside" - ], - "no-caller": "error", - "quotes": [ - "error", - "double" - ], - "no-undef": "error", - "no-unused-vars": [ - "error", - { - "args": "all", - "argsIgnorePattern": "^_" - } - ], - "operator-linebreak": [ - "error", - "after" - ], - "comma-style": [ - "error", - "last" - ], - "camelcase": [ - "error", - { - "properties": "never" - } - ], - "dot-notation": [ - "error", - { - "allowPattern": "^[a-z]+(_[a-z]+)+$" - } - ], - "max-len": [ - "error", - { - "code": 100, - "ignoreComments": true, - "ignoreUrls": true, - "ignoreRegExpLiterals": true - } - ], - "no-mixed-spaces-and-tabs": "error", - "no-trailing-spaces": "error", - "no-irregular-whitespace": "error", - "no-multi-str": "error", - "comma-dangle": [ - "error", - "never" - ], - "comma-spacing": [ - "error", - { - "before": false, - "after": true - } - ], - "space-before-blocks": [ - "error", - "always" - ], - "space-in-parens": [ - "error", - "always" - ], - "keyword-spacing": [ - 2 - ], - "semi": [ - "error", - "always" - ], - "semi-spacing": [ - "error", - { - // Because of the `for ( ; ...)` requirement - // "before": true, - "after": true - } - ], - "no-extra-semi": "error", - "space-infix-ops": "error", - "eol-last": "error", - "lines-around-comment": [ - "error", - { - "beforeLineComment": true - } - ], - "linebreak-style": [ - "error", - "unix" - ], - "no-with": "error", - "brace-style": "error", - "space-before-function-paren": [ - "error", - "never" - ], - "no-loop-func": "error", - "no-spaced-func": "error", - "key-spacing": [ - "error", - { - "beforeColon": false, - "afterColon": true - } - ], - "space-unary-ops": [ - "error", - { - "words": false, - "nonwords": false - } - ], - "no-multiple-empty-lines": 2 - } -} diff --git a/index.js b/index.js new file mode 100644 index 0000000..0f95e4c --- /dev/null +++ b/index.js @@ -0,0 +1,104 @@ +module.exports = { + rules: { + "no-negated-in-lhs": "error", + "no-cond-assign": [ "error", "except-parens" ], + curly: [ "error", "all" ], + "object-curly-spacing": [ "error", "always" ], + "computed-property-spacing": [ "error", "always" ], + "array-bracket-spacing": [ "error", "always" ], + eqeqeq: [ "error", "smart" ], + "no-unused-expressions": "error", + "no-sequences": "error", + "no-nested-ternary": "error", + "no-unreachable": "error", + "wrap-iife": [ "error", "inside" ], + "no-caller": "error", + quotes: [ "error", "double" ], + "no-undef": "error", + "no-unused-vars": [ + "error", + { + args: "all", + argsIgnorePattern: "^_" + } + ], + "operator-linebreak": [ "error", "after" ], + "comma-style": [ "error", "last" ], + camelcase: [ + "error", + { + properties: "never" + } + ], + "dot-notation": [ + "error", + { + allowPattern: "^[a-z]+(_[a-z]+)+$" + } + ], + "max-len": [ + "error", + { + code: 100, + ignoreComments: true, + ignoreUrls: true, + ignoreRegExpLiterals: true + } + ], + "no-mixed-spaces-and-tabs": "error", + "no-trailing-spaces": "error", + "no-irregular-whitespace": "error", + "no-multi-str": "error", + "comma-dangle": [ "error", "never" ], + "comma-spacing": [ + "error", + { + before: false, + after: true + } + ], + "space-before-blocks": [ "error", "always" ], + "space-in-parens": [ "error", "always" ], + "keyword-spacing": [ 2 ], + semi: [ "error", "always" ], + "semi-spacing": [ + "error", + { + + // Because of the `for ( ; ...)` requirement + // before: true, + after: true + } + ], + "no-extra-semi": "error", + "space-infix-ops": "error", + "eol-last": "error", + "lines-around-comment": [ + "error", + { + beforeLineComment: true + } + ], + "linebreak-style": [ "error", "unix" ], + "no-with": "error", + "brace-style": "error", + "space-before-function-paren": [ "error", "never" ], + "no-loop-func": "error", + "no-spaced-func": "error", + "key-spacing": [ + "error", + { + beforeColon: false, + afterColon: true + } + ], + "space-unary-ops": [ + "error", + { + words: false, + nonwords: false + } + ], + "no-multiple-empty-lines": 2 + } +}; diff --git a/package.json b/package.json index 8dbfc5f..7849b6a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "eslint-config-jquery", "version": "3.0.0", "description": "jQuery eslint config", - "main": ".eslintrc.json", + "main": "index.js", "scripts": { "test": "eslint test/fixtures/*.js" }, @@ -21,7 +21,7 @@ "eslintconfig" ], "files": [ - ".eslintrc.json" + "index.js" ], "author": "Gaidarenko Oleg ", "license": "MIT", diff --git a/test/fixtures/.eslintrc b/test/fixtures/.eslintrc deleted file mode 100644 index 76b673f..0000000 --- a/test/fixtures/.eslintrc +++ /dev/null @@ -1,16 +0,0 @@ -globals: - window: true - define: true - module: true - Symbol: false - -extends: ../../.eslintrc.json - -root: true - -rules: - // For the built version - // TODO: do not use the built version to check the code - no-multiple-empty-lines: "off" - max-len: "off" - one-var: "off" diff --git a/test/fixtures/.eslintrc.js b/test/fixtures/.eslintrc.js new file mode 100644 index 0000000..cc9b8b4 --- /dev/null +++ b/test/fixtures/.eslintrc.js @@ -0,0 +1,21 @@ +module.exports = { + globals: { + window: true, + define: true, + module: true, + Symbol: false + }, + + extends: "../../.eslintrc.js", + + root: true, + + rules: { + + // For the built version + // TODO: do not use the built version to check the code + "no-multiple-empty-lines": "off", + "max-len": "off", + "one-var": "off" + } +};