diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 76add87..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -dist \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index eafc0db..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "env": { - "commonjs": true, - "es2021": true, - "node": true - }, - "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 12, - "warnOnUnsupportedTypeScriptVersion": false - }, - "plugins": ["@typescript-eslint"], - "rules": { - "indent": ["off"], - "@typescript-eslint/indent": ["error", 4, { "SwitchCase": 1 }], - "linebreak-style": ["error", "unix"], - "quotes": ["error", "double"], - "semi": ["error", "always"], - "strict": "error", - "no-var": "error", - "no-console": ["warn", { "allow": ["info", "error", "warn"] }], - "array-callback-return": "error", - "yoda": "error", - "@typescript-eslint/no-unused-vars": ["error", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }], - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "prefer-const": ["error", { "destructuring": "all" }] - } -} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..a47eb85 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,40 @@ +name: Lint Code + +on: + push: + branches: + - '*' + pull_request: + branches: + - '*' + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + # Sets up Node.js environment + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + # Installs dependencies + - name: Install dependencies + run: npm install + + # Runs ESLint + - name: Run ESLint + run: npx eslint --fix ./src + + # Displays result + - name: Check for ESLint errors + run: | + if npx eslint --fix ./src; then + echo "Linting passed!" + else + echo "Linting failed!" + exit 1 + fi diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 76add87..0000000 --- a/.prettierignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -dist \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 804f15a..0000000 --- a/.prettierrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "tabWidth": 4, - "useTabs": false, - "endOfLine": "lf", - "semi": true, - "singleQuote": false, - "arrowParens": "always", - "trailingComma": "all", - "bracketSpacing": true, - "printWidth": 120, - "proseWrap": "always", - "embeddedLanguageFormatting": "auto" -} \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..152ba99 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,45 @@ +import eslint from '@eslint/js'; +import tseslint from 'typescript-eslint'; +import typescriptParser from '@typescript-eslint/parser'; +import stylisticJs from '@stylistic/eslint-plugin-js'; + +export default [ + eslint.configs.recommended, + ...tseslint.configs.recommended, + { + ignores: ['dist', 'node_modules'], + plugins: { + '@stylistic/js': stylisticJs, + }, + languageOptions: { + sourceType: 'module', + ecmaVersion: 2024, + parser: typescriptParser + }, + rules: { + 'strict': 'error', + 'no-var': 'error', + 'array-callback-return': 'error', + 'yoda': 'error', + '@stylistic/js/indent': [ + 'error', + 4, + ], + '@stylistic/js/linebreak-style': [ + 'error', + 'unix' + ], + '@stylistic/js/quotes': [ + 'error', + 'double' + ], + '@stylistic/js/semi': [ + 'error', + 'always' + ], + '@typescript-eslint/no-unused-vars': 'error', + '@typescript-eslint/ban-ts-comment': 'off', + '@typescript-eslint/no-non-null-assertion': 'off' + } + } +];