From 0468748759928161a004df936c77e9f26df8f14f Mon Sep 17 00:00:00 2001 From: "Marcus R. Brown" Date: Sun, 30 Jul 2023 22:44:48 -0700 Subject: [PATCH] feat: convert config to YAML and cleanup (#67) --- .editorconfig | 2 +- .eslintignore | 4 -- .eslintrc.json | 54 ---------------------- .eslintrc.yaml | 53 +++++++++++++++++++++ .github/renovate.json | 4 +- .github/workflows/codeql-analysis.yaml | 64 +++++++++++++------------- .prettierignore | 3 +- .prettierrc.json | 10 ---- .prettierrc.yaml | 17 +++++++ .yarnrc.yml | 2 +- README.md | 2 +- __tests__/main.test.ts | 2 +- action.yml => action.yaml | 0 jest.config.js | 6 +-- package.json | 6 +-- tsconfig.json | 16 +++---- 16 files changed, 123 insertions(+), 122 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json create mode 100644 .eslintrc.yaml delete mode 100644 .prettierrc.json create mode 100644 .prettierrc.yaml rename action.yml => action.yaml (100%) diff --git a/.editorconfig b/.editorconfig index 1ed453a3..827798dd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,7 @@ root = true end_of_line = lf insert_final_newline = true -[*.{js,json,yml}] +[*.{js,json,yaml,yml}] charset = utf-8 indent_style = space indent_size = 2 diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 42ceb9a5..00000000 --- a/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -dist/ -lib/ -node_modules/ -jest.config.js diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index b7bdcf3d..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "env": { - "node": true, - "es6": true, - "jest/globals": true - }, - "plugins": ["jest", "@typescript-eslint"], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 9, - "sourceType": "module", - "project": "./tsconfig.json" - }, - "rules": { - "i18n-text/no-en": "off", - "eslint-comments/no-use": "off", - "import/no-namespace": "off", - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}], - "@typescript-eslint/no-require-imports": "error", - "@typescript-eslint/array-type": "error", - "@typescript-eslint/await-thenable": "error", - "@typescript-eslint/ban-ts-comment": "error", - "camelcase": "off", - "@typescript-eslint/consistent-type-assertions": "error", - "@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}], - "@typescript-eslint/func-call-spacing": ["error", "never"], - "@typescript-eslint/no-array-constructor": "error", - "@typescript-eslint/no-empty-interface": "error", - "@typescript-eslint/no-explicit-any": "error", - "@typescript-eslint/no-extraneous-class": "error", - "@typescript-eslint/no-for-in-array": "error", - "@typescript-eslint/no-inferrable-types": "error", - "@typescript-eslint/no-misused-new": "error", - "@typescript-eslint/no-namespace": "error", - "@typescript-eslint/no-non-null-assertion": "warn", - "@typescript-eslint/no-unnecessary-qualifier": "error", - "@typescript-eslint/no-unnecessary-type-assertion": "error", - "@typescript-eslint/no-useless-constructor": "error", - "@typescript-eslint/no-var-requires": "error", - "@typescript-eslint/prefer-for-of": "warn", - "@typescript-eslint/prefer-function-type": "warn", - "@typescript-eslint/prefer-includes": "error", - "@typescript-eslint/prefer-string-starts-ends-with": "error", - "@typescript-eslint/promise-function-async": "error", - "@typescript-eslint/require-array-sort-compare": "error", - "@typescript-eslint/restrict-plus-operands": "error", - "semi": "off", - "@typescript-eslint/semi": ["error", "never"], - "@typescript-eslint/type-annotation-spacing": "error", - "@typescript-eslint/unbound-method": "error" - } - } \ No newline at end of file diff --git a/.eslintrc.yaml b/.eslintrc.yaml new file mode 100644 index 00000000..b0329ddc --- /dev/null +++ b/.eslintrc.yaml @@ -0,0 +1,53 @@ +--- +root: true +env: + node: true + es6: true + 'jest/globals': true +extends: ['eslint:recommended', 'plugin:jest/recommended', 'plugin:@typescript-eslint/recommended'] +ignorePatterns: ['__tests__', '.yarn', 'dist', 'lib', 'node_modules', 'jest.config.js'] +plugins: ['jest', '@typescript-eslint'] +parser: '@typescript-eslint/parser' +parserOptions: + ecmaVersion: 2018 + sourceType: module + project: './tsconfig.json' +rules: + 'i18n-text/no-en': 'off' + 'eslint-comments/no-use': 'off' + 'import/no-namespace': 'off' + 'no-unused-vars': 'off' + '@typescript-eslint/no-unused-vars': 'error' + '@typescript-eslint/explicit-member-accessibility': ['error', {'accessibility': 'no-public'}] + '@typescript-eslint/no-require-imports': 'error' + '@typescript-eslint/array-type': 'error' + '@typescript-eslint/await-thenable': 'error' + '@typescript-eslint/ban-ts-comment': 'error' + 'camelcase': 'off' + '@typescript-eslint/consistent-type-assertions': 'error' + '@typescript-eslint/explicit-function-return-type': ['error', {'allowExpressions': true}] + '@typescript-eslint/func-call-spacing': ['error', 'never'] + '@typescript-eslint/no-array-constructor': 'error' + '@typescript-eslint/no-empty-interface': 'error' + '@typescript-eslint/no-explicit-any': 'error' + '@typescript-eslint/no-extraneous-class': 'error' + '@typescript-eslint/no-for-in-array': 'error' + '@typescript-eslint/no-inferrable-types': 'error' + '@typescript-eslint/no-misused-new': 'error' + '@typescript-eslint/no-namespace': 'error' + '@typescript-eslint/no-non-null-assertion': 'warn' + '@typescript-eslint/no-unnecessary-qualifier': 'error' + '@typescript-eslint/no-unnecessary-type-assertion': 'error' + '@typescript-eslint/no-useless-constructor': 'error' + '@typescript-eslint/no-var-requires': 'error' + '@typescript-eslint/prefer-for-of': 'warn' + '@typescript-eslint/prefer-function-type': 'warn' + '@typescript-eslint/prefer-includes': 'error' + '@typescript-eslint/prefer-string-starts-ends-with': 'error' + '@typescript-eslint/promise-function-async': 'error' + '@typescript-eslint/require-array-sort-compare': 'error' + '@typescript-eslint/restrict-plus-operands': 'error' + 'semi': 'off' + '@typescript-eslint/semi': ['error', 'never'] + '@typescript-eslint/type-annotation-spacing': 'error' + '@typescript-eslint/unbound-method': 'error' diff --git a/.github/renovate.json b/.github/renovate.json index 54a75ff2..b8b27b77 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,6 +1,4 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "local>bfra-me/renovate-config" - ] + "extends": ["local>bfra-me/renovate-config"] } diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml index 8a1acf20..1c6939d5 100644 --- a/.github/workflows/codeql-analysis.yaml +++ b/.github/workflows/codeql-analysis.yaml @@ -24,35 +24,35 @@ jobs: language: [TypeScript] steps: - - name: Checkout repository - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@0ba4244466797eb048eb91a6cd43d5c03ca8bd05 # v2.21.2 - with: - languages: ${{ matrix.language }} - source-root: src - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@0ba4244466797eb048eb91a6cd43d5c03ca8bd05 # v2.21.2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@0ba4244466797eb048eb91a6cd43d5c03ca8bd05 # v2.21.2 + - name: Checkout repository + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@0ba4244466797eb048eb91a6cd43d5c03ca8bd05 # v2.21.2 + with: + languages: ${{ matrix.language }} + source-root: src + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@0ba4244466797eb048eb91a6cd43d5c03ca8bd05 # v2.21.2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@0ba4244466797eb048eb91a6cd43d5c03ca8bd05 # v2.21.2 diff --git a/.prettierignore b/.prettierignore index 21869472..e7f509e9 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ +.yarn/ dist/ lib/ -node_modules/ \ No newline at end of file +node_modules/ diff --git a/.prettierrc.json b/.prettierrc.json deleted file mode 100644 index c34bafcb..00000000 --- a/.prettierrc.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "printWidth": 80, - "tabWidth": 2, - "useTabs": false, - "semi": false, - "singleQuote": true, - "trailingComma": "none", - "bracketSpacing": false, - "arrowParens": "avoid" -} diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 00000000..200640ac --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,17 @@ +--- +arrowParens: avoid +bracketSpacing: false +overrides: + - files: + - '*.json' + options: + singleQuote: false + trailingComma: none + - files: + - '.vscode/*.json' + options: + tabWidth: 4 +printWidth: 120 +semi: false +singleQuote: true +tabWidth: 2 diff --git a/.yarnrc.yml b/.yarnrc.yml index b8b0dc3e..25691b94 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -2,6 +2,6 @@ nodeLinker: pnpm plugins: - path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs - spec: "@yarnpkg/plugin-typescript" + spec: '@yarnpkg/plugin-typescript' yarnPath: .yarn/releases/yarn-3.6.1.cjs diff --git a/README.md b/README.md index 92e0183c..4c76aa67 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Use this template to bootstrap the creation of a TypeScript action. :rocket: This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance. -If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) +If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) ## Create an action from this template diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 0c435e12..09c74468 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -22,7 +22,7 @@ test('test runs', () => { const np = process.execPath const ip = path.join(__dirname, '..', 'dist', 'index.js') const options: cp.ExecFileSyncOptions = { - env: process.env + env: process.env, } console.log(cp.execFileSync(np, [ip], options).toString()) }) diff --git a/action.yml b/action.yaml similarity index 100% rename from action.yml rename to action.yaml diff --git a/jest.config.js b/jest.config.js index 5a822283..f5d57165 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,7 +3,7 @@ module.exports = { moduleFileExtensions: ['js', 'ts'], testMatch: ['**/*.test.ts'], transform: { - '^.+\\.ts$': 'ts-jest' + '^.+\\.ts$': 'ts-jest', }, - verbose: true -} \ No newline at end of file + verbose: true, +} diff --git a/package.json b/package.json index 0c745055..390e9e74 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "main": "dist/index.js", "scripts": { "build": "ncc build --license licenses.txt -o dist src/main.ts", - "format": "prettier --write '**/*.ts'", - "check-format": "prettier --check '**/*.ts'", - "lint": "eslint src/**/*.ts", + "format": "prettier --write .", + "check-format": "prettier --check .", + "lint": "eslint . --report-unused-disable-directives --max-warnings 0", "test": "jest" }, "repository": { diff --git a/tsconfig.json b/tsconfig.json index f6e7cb5b..ca6fbb33 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,12 @@ { "compilerOptions": { - "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - "outDir": "./lib", /* Redirect output structure to the directory. */ - "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "target": "es6", + "module": "commonjs", + "outDir": "./lib", + "strict": true, + "noImplicitAny": true, + "esModuleInterop": true }, - "exclude": ["node_modules", "**/*.test.ts"] + "exclude": ["node_modules", "**/*.test.ts"], + "include": ["src"] }