diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 4ae03c16adf668c66a70523d7ac2779b5eaf91a3..0000000000000000000000000000000000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,85 +0,0 @@ -"use strict"; -module.exports = { - env: { - es2021: true, - node: true, - }, - extends: "eslint:recommended", - parserOptions: { - sourceType: "script", - ecmaVersion: 2022, - }, - rules: { - // Annoyances - "no-inner-declarations": "off", - "no-useless-escape": "warn", - "require-atomic-updates": "off", - "linebreak-style": "off", - - // Performance/consistency - "eqeqeq": [ - "error", - "always", - { - "null": "ignore", - }, - ], - "strict": [ - "error", - "global", - ], - "no-var": ["error"], - "prefer-const": ["warn"], - "prefer-template": ["error"], - - // Stylistic - "array-element-newline": [ - "error", - "consistent", - ], - "comma-dangle": ["error", "always-multiline"], - "comma-style": ["error", "last"], - "indent": [ - "error", - 4, - ], - "quotes": [ - "error", - "double", - ], - "semi": [ - "error", - "always", - ], - "no-empty": [ - "error", - { - "allowEmptyCatch": true, - }, - ], - "no-extra-parens": "error", - "brace-style": [ - "error", - "1tbs", - ], - "object-curly-spacing": [ - "error", - "always", - ], - "eol-last": ["warn", "always"], - "key-spacing": ["error"], - "keyword-spacing": ["error"], - "lines-between-class-members": ["error"], - "newline-per-chained-call": ["warn"], - "no-unneeded-ternary": ["warn"], - "prefer-object-spread": ["warn"], - "semi-spacing": ["error"], - "space-before-blocks": ["error", "always"], - "spaced-comment": ["error", "always"], - "arrow-body-style": ["warn", "as-needed"], - "arrow-spacing": ["error"], - }, - globals: { - "BigInt": true, - }, -}; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000000000000000000000000000000000000..eb63b14194d448ac228770fa3131045a1f8624af --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,73 @@ +import stylistic from "@stylistic/eslint-plugin"; +import js from "@eslint/js"; +import globals from "globals"; + +export default [ + js.configs.recommended, + stylistic.configs.customize({ + blockSpacing: true, + braceStyle: "1tbs", + indent: 4, + jsx: true, + quotes: "double", + semi: true, + commaDangle: "always-multiline", + }), + { + files: ["**/*.js"], + languageOptions: { + sourceType: "commonjs", + globals: { + ...globals.commonjs, + }, + }, + }, + { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + }, + rules: { + // Annoyances + "no-inner-declarations": "off", + "require-atomic-updates": "off", + "linebreak-style": "off", + + // Performance/consistency + "eqeqeq": [ + "error", + "always", + { + null: "ignore", + }, + ], + "strict": [ + "error", + "global", + ], + "no-var": ["error"], + "prefer-const": ["warn"], + "prefer-template": ["error"], + + // Stylistic + "@stylistic/array-element-newline": [ + "error", + "consistent", + ], + "no-empty": [ + "error", + { + allowEmptyCatch: true, + }, + ], + "@stylistic/no-extra-parens": "error", + "@stylistic/newline-per-chained-call": ["warn"], + "no-unneeded-ternary": ["warn"], + "prefer-object-spread": ["warn"], + "prefer-object-has-own": ["warn"], + "arrow-body-style": ["warn", "as-needed"], + }, + }, +]; diff --git a/index.js b/index.js deleted file mode 100644 index 9b30f9fe439e54d975cd9adf39a37ae9a9b10455..0000000000000000000000000000000000000000 --- a/index.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -module.exports = require("./.eslintrc.js"); diff --git a/package.json b/package.json index 5655843313800ad299946dc1e2c9c6ab5ca1c304..c64a6952b8f9d8ad6c555113dd8af8bca8a1a6c7 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "@tt-bot-dev/eslint-config", - "version": "1.1.0", + "version": "1.2.0", "description": "The ESLint configuration used across all tt-bot-dev repositories.", - "main": "index.js", + "main": "eslint.config.mjs", + "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -22,7 +23,12 @@ }, "homepage": "https://owo.codes/tt.bot/frameworks/eslint-config", "peerDependencies": { - "eslint": "^8.5.0" + "eslint": "^8.57.0" }, - "private": false + "private": false, + "dependencies": { + "@eslint/js": "^8.57.0", + "@stylistic/eslint-plugin": "^1.7.0", + "globals": "^14.0.0" + } }