Skip to content

Commit

Permalink
chore: reuse import.meta.dirname & update README
Browse files Browse the repository at this point in the history
  • Loading branch information
sixmen committed Oct 29, 2024
1 parent 68473dd commit 59db4ff
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 52 deletions.
48 changes: 35 additions & 13 deletions TypeScript/eslint-www/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,43 @@ npm install --save-dev @croquiscom/eslint-config-www eslint typescript

## Usage in www Projects

```json
{
"extends": [
"@croquiscom/eslint-config-www"
],
"overrides": [
...custom overrides
],
"rules": {
...custom rules
}
}
```javascript
import baseConfig from '@croquiscom/eslint-config-www/index.mjs';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
...baseConfig,
{
languageOptions: {
globals: {
...globals.browser,
},

parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
project: `${import.meta.dirname}/tsconfig.json`,
},
},
settings: {
'import/resolver': {
typescript: {
project: `${import.meta.dirname}/tsconfig.json`,
},
},
},
rules: {},
},
{
ignores: ['eslint.config.mjs'],
},
);
```
You can override the settings from `eslint-config-www` by editing the `.eslintrc.json` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website.
You can override the settings from `eslint-config-www` by editing the `eslint.config.mjs` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website.
### PR
Expand Down
9 changes: 3 additions & 6 deletions TypeScript/eslint-www/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import path from 'path';
import url from 'url';
import tseslint from 'typescript-eslint';
import baseConfig from './requiring-type-checking.mjs';

const dirname = path.dirname(url.fileURLToPath(import.meta.url));

export default tseslint.config(...baseConfig, {
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: dirname,
tsconfigRootDir: import.meta.dirname,
project: `${import.meta.dirname}/tsconfig.json`,
},
},
settings: {
'import/resolver': {
typescript: {
project: `${dirname}/tsconfig.json`,
project: `${import.meta.dirname}/tsconfig.json`,
},
},
},
Expand Down
18 changes: 9 additions & 9 deletions TypeScript/eslint-www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
"name": "@croquiscom/eslint-config-www",
"version": "3.0.0",
"description": "ESLint configuration used by Kakaostyle web projects",
"main": "index.js",
"main": "index.mjs",
"license": "MIT",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"repository": {
"type": "git",
"url": "https://github.com/croquiscom/style-guide",
"directory": "Typescript/eslint-www"
},
"bugs": {
"url": "https://github.com/croquiscom/style-guide/issues"
},
"scripts": {
"changeset": "changeset",
"release": "changeset publish"
},
"license": "MIT",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"bugs": {
"url": "https://github.com/croquiscom/style-guide/issues"
},
"dependencies": {
"@eslint/compat": "^1.2.1",
"eslint-import-resolver-typescript": "^3.6.3",
Expand Down
40 changes: 33 additions & 7 deletions TypeScript/eslint/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
# 설정 방법

`npm install --save-dev eslint @croquiscom/eslint-config`로 패키지를 추가하고, 다음과 같이 `.eslintrc.js`를 작성한다.
`npm install --save-dev eslint typescript @croquiscom/eslint-config`로 패키지를 추가하고, 다음과 같이 `eslint.config.mjs`를 작성한다.
(각 프로젝트에 맞는 추가 설정 필요)

```javascript
module.exports = {
root: true,
extends: ['@croquiscom/eslint-config/requiring-type-checking'],
parserOptions: {
project: [`${__dirname}/tsconfig.json`],
import baseConfig from '@croquiscom/eslint-config/requiring-type-checking.mjs';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
...baseConfig,
{
languageOptions: {
globals: {
...globals.node,
},

parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
project: `${import.meta.dirname}/tsconfig.json`,
},
},
settings: {
'import/resolver': {
typescript: {
project: `${import.meta.dirname}/tsconfig.json`,
},
},
},
rules: {},
},
{
ignores: ['eslint.config.mjs'],
},
};
);
```
9 changes: 3 additions & 6 deletions TypeScript/eslint/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import path from 'path';
import url from 'url';
import tseslint from 'typescript-eslint';
import baseConfig from './requiring-type-checking.mjs';

const dirname = path.dirname(url.fileURLToPath(import.meta.url));

export default tseslint.config(...baseConfig, {
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: dirname,
tsconfigRootDir: import.meta.dirname,
project: `${import.meta.dirname}/tsconfig.json`,
},
},
settings: {
'import/resolver': {
typescript: {
project: `${dirname}/tsconfig.json`,
project: `${import.meta.dirname}/tsconfig.json`,
},
},
},
Expand Down
7 changes: 5 additions & 2 deletions TypeScript/eslint/package-lock.json

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

18 changes: 9 additions & 9 deletions TypeScript/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
"name": "@croquiscom/eslint-config",
"version": "3.0.0",
"description": "ESLint configuration used by Kakaostyle Node.js projects",
"main": "index.js",
"main": "index.mjs",
"license": "MIT",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"repository": {
"type": "git",
"url": "https://github.com/croquiscom/style-guide",
"directory": "Typescript/eslint"
},
"bugs": {
"url": "https://github.com/croquiscom/style-guide/issues"
},
"scripts": {
"changeset": "changeset",
"release": "changeset publish"
},
"license": "MIT",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"bugs": {
"url": "https://github.com/croquiscom/style-guide/issues"
},
"dependencies": {
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.31.0",
Expand Down

0 comments on commit 59db4ff

Please sign in to comment.