generated from kurone-kito/yarn-project-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(root,ts): migrated the eslint flat config
- Loading branch information
1 parent
567dec2
commit f02ec03
Showing
20 changed files
with
571 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ import: | |
- '@kurone-kito/cspell-config' | ||
usePnP: true | ||
version: '0.2' | ||
words: | ||
- TSES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Linter } from 'eslint'; | ||
import { compat } from './utils.mjs'; | ||
|
||
/** The configuration for ESLint to use the Airbnb style guide. */ | ||
export const airbnbConfig: readonly Linter.Config[] = [ | ||
...compat.extends('airbnb-base'), | ||
// ...compat.extends('airbnb-typescript/base'), | ||
{ | ||
languageOptions: { | ||
parserOptions: { project: true, tsconfigRootDir: process.cwd() }, | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import type { Linter } from 'eslint'; | ||
// @ts-ignore | ||
import json from 'eslint-plugin-json'; | ||
import pluginYaml from 'eslint-plugin-yaml'; | ||
|
||
/** The ESLint configuration for data language files. */ | ||
export const dataConfig: readonly Linter.Config[] = [ | ||
{ files: ['**/*.json'], ...json.configs['recommended'] }, | ||
(pluginYaml as any).configs.recommended, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import type { Linter } from 'eslint'; | ||
import { compat } from './utils.mjs'; | ||
|
||
/** Additional configuration for the `import` plugin. */ | ||
export const additionalImportConfig: readonly Linter.Config[] = [ | ||
{ | ||
files: ['*.?(c)js?(x)'], | ||
rules: { | ||
/** | ||
* Allow `require` syntax only for JavaScript. By default, it is | ||
* completely prohibited. | ||
* | ||
* There are many situations where pure JavaScript is used outside | ||
* the scope of transpiling, such as in various configuration files, | ||
* making the `import` syntax challenging. | ||
*/ | ||
'@typescript-eslint/no-var-requires': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['*.?([cm])js?(x)'], | ||
rules: { | ||
/** | ||
* Allow type inference of return values of exported functions, etc., | ||
* only for JavaScript. By default, it is allowed with a warning. | ||
* | ||
* There are many situations where CommonJS is used outside the scope | ||
* of transpiling, such as in various configuration files, | ||
* where it is challenging to make type definitions mandatory. | ||
*/ | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
}, | ||
}, | ||
{ | ||
rules: { | ||
/** | ||
* Forces import without extensions for internal modules only. | ||
* The default is full enforcement. | ||
* | ||
* Because it interferes with imports such as `lodash-es` | ||
* in the ES modules environment. | ||
*/ | ||
'import/extensions': [ | ||
'error', | ||
'never', | ||
{ js: 'ignorePackages', json: 'ignorePackages' }, | ||
], | ||
/** | ||
* Prohibit dependencies on `devDependencies`, except for specific | ||
* files. By default, this is a total ban. | ||
* | ||
* There is no need for strict separation of dependent packages since | ||
* they are internally tree shaken by bundlers. Still, some packages | ||
* are separated into `devDependencies` to make it easier to organize. | ||
*/ | ||
'import/no-extraneous-dependencies': [ | ||
'error', | ||
{ | ||
devDependencies: [ | ||
'**/*.config.?([cm])[jt]s?(x)', | ||
'**/*.spec.?([cm])[jt]s?(x)', | ||
'**/*.test.?([cm])[jt]s?(x)', | ||
], | ||
}, | ||
], | ||
/** | ||
* Allow with a warning that the arbitrary reordering in the | ||
* import syntax. The default is to allow it unconditionally. | ||
* | ||
* in order to deal with the snowballing problem of the import part. | ||
*/ | ||
'import/order': [ | ||
'warn', | ||
{ | ||
alphabetize: { caseInsensitive: true, order: 'asc' }, | ||
groups: [ | ||
'builtin', | ||
'external', | ||
'internal', | ||
'parent', | ||
'sibling', | ||
'index', | ||
'object', | ||
], | ||
'newlines-between': 'never', | ||
}, | ||
], | ||
/** | ||
* Allow with a warning that the arbitrary reordering in the | ||
* import syntax. The default is to allow it unconditionally. | ||
* | ||
* To deal with the snowballing problem of the import part. | ||
*/ | ||
'sort-imports': [ | ||
'warn', | ||
{ ignoreCase: true, ignoreDeclarationSort: true }, | ||
], | ||
}, | ||
}, | ||
]; | ||
|
||
/** The ESLint configuration for the `import` plugin. */ | ||
export const importConfig: readonly Linter.Config[] = [ | ||
...compat.extends('plugin:import/recommended'), | ||
...compat.extends('plugin:import/typescript'), | ||
...additionalImportConfig, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
import type { Linter } from 'eslint'; | ||
import tsEslint from 'typescript-eslint'; | ||
import { airbnbConfig } from './airbnb.mjs'; | ||
import { dataConfig } from './data.mjs'; | ||
import { ignoreConfig } from './ignore.mjs'; | ||
import { importConfig, additionalImportConfig } from './import.mjs'; | ||
import { jsdocConfig, additionalJsdocConfig } from './jsdoc.mjs'; | ||
import { markdownConfig } from './markdown.mjs'; | ||
import { additionalNodeConfig, nodeConfig } from './node.mjs'; | ||
import { additionalStyleConfig, styleConfig } from './style.mjs'; | ||
import { additionalTsConfig, tsConfig } from './ts.mjs'; | ||
|
||
/** ESLint configuration for generic TypeScript projects. */ | ||
const config: readonly Linter.Config[] = [...ignoreConfig, ...dataConfig]; | ||
|
||
export default config; | ||
export default tsEslint.config( | ||
...([ | ||
...ignoreConfig, | ||
...markdownConfig, | ||
...dataConfig, | ||
...styleConfig, | ||
...jsdocConfig, | ||
...importConfig, | ||
...nodeConfig, | ||
...tsConfig, | ||
...airbnbConfig, | ||
...additionalStyleConfig, | ||
...additionalJsdocConfig, | ||
...additionalImportConfig, | ||
...additionalNodeConfig, | ||
...additionalTsConfig, | ||
] as tsEslint.ConfigWithExtends[]), | ||
); |
Oops, something went wrong.