Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update .eslintrc to eslint.config.js name/format #899

Closed
intcreator opened this issue Oct 29, 2024 · 2 comments Β· Fixed by #913
Closed

update .eslintrc to eslint.config.js name/format #899

intcreator opened this issue Oct 29, 2024 · 2 comments Β· Fixed by #913
Assignees
Labels
released type:feature New feature or feature improvement & requests

Comments

@intcreator
Copy link
Collaborator

⭐ Suggestion

.eslintrc is now deprecated. we need to update it to eslint.config.js to prepare for future Eslint versions that may require the new format

πŸ’» Use Cases

No response

❌ Related Problems

No response

@intcreator intcreator added the type:feature New feature or feature improvement & requests label Oct 29, 2024
@sheerlox
Copy link
Collaborator

Here's the eslint.config.js from a similar TypeScript project of mine, might need some adjustments though.

const globals = require("globals");
const tsEslint = require('typescript-eslint');
const tsEslintPlugin = require('@typescript-eslint/eslint-plugin');
const tsEslintParser = require('@typescript-eslint/parser');
const prettierEslint = require('eslint-config-prettier');
const jest = require('eslint-plugin-jest');

module.exports = tsEslint.config(
  {
    files: ["src/**/*.ts"],
  },
  {
    ignores: [
      "dist/",
      "**/*.js",
      "**/*.cjs",
      "**/*.mjs",
      "**/*.d.ts"
    ]
  },
  ...tsEslint.configs.strictTypeChecked,
  {
    languageOptions: {
      parser: tsEslintParser,
      parserOptions: {
        project: 'tsconfig.json',
        tsconfigRootDir: __dirname,
        sourceType: 'module',
      },
      globals: {
        ...globals.node,
        ...globals.jest,
      },
    },
    plugins: {
      '@typescript-eslint': tsEslintPlugin,
    },
    rules: {
      '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
      '@typescript-eslint/no-invalid-void-type': ['error', { allowAsThisParameter: true }],
      '@typescript-eslint/naming-convention': [
        'warn',
        {
          selector: 'interface',
          format: ['PascalCase'],
          custom: {
            regex: '^I[A-Z]',
            match: true,
          },
        },
        {
          selector: ['variableLike', 'function'],
          format: ['camelCase'],
          leadingUnderscore: 'allow',
        },
        {
          selector: ['variable'],
          format: ['camelCase', 'UPPER_CASE'],
        },
        {
          selector: 'variable',
          types: ['boolean'],
          format: ['PascalCase'],
          prefix: ['is', 'should', 'has', 'can', 'did', 'will'],
        },
      ],
      "@typescript-eslint/restrict-template-expressions": [
        "error",
        {
          allowAny: false,
          allowNullish: false,
          allowBoolean: true,
          allowNumber: true,
          allowRegExp: true,
          allowNever: false,
        }
      ]
    },
  },
  {
    files: ['src/**/*.module.ts'],
    rules: {
      '@typescript-eslint/no-extraneous-class': 'off',
    },
  },
  {
    files: ['src/**/*.spec.ts'],
    ...jest.configs['flat/recommended'],
    rules: {
      ...jest.configs['flat/recommended'].rules,
      ...jest.configs['flat/style'].rules,
      '@typescript-eslint/unbound-method': 'off',
      'jest/unbound-method': 'error',
    },
  },
  prettierEslint
);

@intcreator intcreator self-assigned this Oct 29, 2024
intcreator added a commit that referenced this issue Nov 12, 2024
<!--- Provide a general summary of your changes in the Title above
(following the Conventional Commits standard) -->
<!-- More infos: https://www.conventionalcommits.org -->
<!-- Commit types:
https://github.com/insurgent-lab/conventional-changelog-preset#commit-types-->

## Description

<!--- Describe your changes in detail -->
Migrate .eslintrc to esling.config.mjs. Using .mjs so I can use `import`
(.ts configs are still experimental). Fixed a few lint issues that were
easy, changed one new lint rule to a warn since it wasn't caught before.

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->
<!--- Please link to the issue here: -->

Fixes #899 

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
Using the new flat config for Eslint is required for upgrading to 9.0

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
Ran `npm run lint` and VS Code Eslint plugin many times

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes
that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] If my change introduces a breaking change, I have added a `!`
after the type/scope in the title (see the Conventional Commits
standard).
@ncb000gt
Copy link
Member

πŸŽ‰ This issue has been resolved in version 3.2.1 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

intcreator pushed a commit that referenced this issue Nov 12, 2024
## [3.2.1](v3.2.0...v3.2.1) (2024-11-12)

### πŸ›  Builds

* migrate eslint config to flat style ([#913](#913)) ([38c1044](38c1044)), closes [#899](#899)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released type:feature New feature or feature improvement & requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants