Skip to content

Commit

Permalink
feat: upgrade to eslint v9 (#1234)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
jackton1 and actions-user committed May 4, 2024
1 parent 45253be commit fe8057e
Show file tree
Hide file tree
Showing 14 changed files with 333 additions and 243 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

82 changes: 0 additions & 82 deletions .eslintrc.json

This file was deleted.

10 changes: 7 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ jobs:
run: |
yarn install
- name: Run eslint on changed files
- name: Run ESLint on changed files
uses: tj-actions/eslint-changed-files@v25
with:
token: ${{ secrets.PAT_TOKEN }}
config_path: ".eslintrc.json"
ignore_path: ".eslintignore"
ignore_patterns: |
dist/**
lib/**
node_modules/**
jest.config.js
coverage/**
- name: Run build and test
run: |
Expand Down
6 changes: 3 additions & 3 deletions dist/cleanup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 32 additions & 31 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import globals from 'globals'

import path from 'path'
import {fileURLToPath} from 'url'
import {FlatCompat} from '@eslint/eslintrc'
import pluginJs from '@eslint/js'
import prettierConfig from 'eslint-config-prettier'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'


// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({ baseDirectory: __dirname, recommendedConfig: pluginJs.configs.recommended })

export default [
{ languageOptions: { globals: globals.browser }},
{
ignores: [
'dist/**',
'lib/**',
'node_modules/**',
'jest.config.js',
'coverage/**'
]
},
...compat.extends("standard-with-typescript").map((config) => ({
...config,
files: ["**/*.tsx", "**/*.ts"],
rules: {
...config.rules,
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/prefer-ts-expect-error": "off",
"no-import-assign": "off",
},
})),
prettierConfig, // Turns off all ESLint rules that have the potential to interfere with Prettier rules.
eslintPluginPrettierRecommended,
]
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
moduleFileExtensions: ['js', 'ts'],
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.ts$': 'ts-jest'
'^.+\\.(ts|tsx)$': 'ts-jest',
},
verbose: true,
testTimeout: 10000,
Expand Down
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,30 @@
"uuid": "9.0.1"
},
"devDependencies": {
"@types/jest": "29.5.12",
"@eslint/eslintrc": "^3.0.2",
"@eslint/js": "^9.1.1",
"@types/jest": "^29.5.12",
"@types/node": "20.12.8",
"@types/uuid": "9.0.8",
"@typescript-eslint/eslint-plugin": "7.8.0",
"@typescript-eslint/parser": "7.8.0",
"@vercel/ncc": "0.38.1",
"eslint": "8.57.0",
"eslint": "^9.1.1",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-github": "4.10.2",
"eslint-plugin-i18n-text": "^1.0.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "28.5.0",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-prettier": "^5.0.0-alpha.2",
"eslint-plugin-promise": "^6.0.0",
"globals": "^15.0.0",
"jest": "29.7.0",
"prettier": "3.2.5",
"ts-jest": "29.1.2",
"typescript": "5.4.5"
"ts-jest": "^29.1.2",
"typescript": "<5.4.0"
}
}
3 changes: 2 additions & 1 deletion src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const defaultEnv = {
'INPUT_FILES-FROM-SOURCE-FILE': ''
}

function mockedEnv(testEnvVars: {[key: string]: string}): void {
function mockedEnv(testEnvVars: Record<string, string>): void {
jest.replaceProperty(process, 'env', {...process.env, ...testEnvVars})
}

Expand Down Expand Up @@ -214,6 +214,7 @@ test('returns the paths of the all other files (input files)', async () => {
const EXPECTED_FILENAMES = [
'LICENSE',
'action.yml',
'eslint.config.mjs',
'jest.config.js',
'package.json',
'renovate.json',
Expand Down
Loading

0 comments on commit fe8057e

Please sign in to comment.