Wantedly TypeScript ESLint Configuration
eslint-config-wantedly-typescript provides a comprehensive ESLint configuration tailored for TypeScript projects, specifically designed for Wantedly's development ecosystem. Currently stable at version 4.0.0, this package aligns with the latest ESLint v9 and its new "Flat Config" format, offering a modern approach to linting. It bundles popular plugins and configurations, including `@typescript-eslint` for TypeScript-specific rules, `react` for JSX and React hooks, `import` for import statement validation, `jsx-a11y` for accessibility, `jest` for testing environments, and `prettier` for code formatting integration. While version 4.x exclusively supports the flat config format, earlier versions (3.x and below) provide compatibility with ESLint v8 and its legacy configuration style. The package aims to standardize code style and catch common errors in TypeScript, React, and related JavaScript projects. Releases generally follow major ESLint versions for compatibility updates, with smaller patches for dependency management and bug fixes.
Common errors
-
ESLint: Cannot find module 'eslint-config-wantedly-typescript'
cause Attempting to use `eslint-config-wantedly-typescript` v4.x with a legacy `.eslintrc` file's `extends` property, which expects a CommonJS module or an old configuration format.fixFor v4.x, ensure you are using an `eslint.config.js` file and importing the configuration using ESM syntax: `import { base as configWantedlyTS } from 'eslint-config-wantedly-typescript';` -
Error: You are attempting to use a flat configuration file with a legacy eslint config. You should be using `eslint.config.js` or `eslint.config.mjs` or `eslint.config.cjs`.
cause Running ESLint < v9 or an ESLint instance not configured for Flat Config with an `eslint.config.js` file containing `eslint-config-wantedly-typescript` v4.x.fixUpgrade ESLint to version 9.x or later (`npm install eslint@latest --save-dev`) and ensure your main configuration file is named `eslint.config.js` (or `.mjs`/`.cjs`). -
Parsing error: 'import' and 'export' may only appear with 'sourceType: "module"'
cause Your ESLint configuration is not set up for ESM syntax, but `eslint-config-wantedly-typescript` v4.x itself uses ESM.fixEnsure your `eslint.config.js` or relevant parser options specify `sourceType: 'module'` in the parser configuration. For example: `parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }`.
Warnings
- breaking Version 4.0.0 of `eslint-config-wantedly-typescript` introduces support for ESLint v9 and its new Flat Config format. This is a breaking change for users on ESLint v8 or older, or those using the legacy `.eslintrc` configuration format.
- gotcha The package has a peer dependency on `typescript`. Ensure you have a compatible version installed in your project. Incompatible TypeScript versions can lead to parsing errors or incorrect linting results.
- breaking The `eslint-config-wantedly-typescript` package is now published under the `frolint` monorepo. While the package name remains the same, be aware of related packages like `eslint-plugin-wantedly` and `eslint-plugin-use-macros` also being updated to support ESLint v9.
Install
-
npm install eslint-config-wantedly-typescript -
yarn add eslint-config-wantedly-typescript -
pnpm add eslint-config-wantedly-typescript
Imports
- configWantedlyTS
const configWantedlyTS = require('eslint-config-wantedly-typescript');import { base as configWantedlyTS } from 'eslint-config-wantedly-typescript';
Quickstart
import { base as configWantedlyTS } from 'eslint-config-wantedly-typescript';
export default [
...configWantedlyTS,
{
// Optional: Add project-specific overrides or additional rules here.
// For example, to disable a rule:
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'react/react-in-jsx-scope': 'off' // Example for React 17+ / New JSX Transform
}
},
{
// Define files glob patterns for this configuration scope
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
// You might need to specify parserOptions if your project uses different TypeScript settings
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true
}
}
}
];