Skip to content

Commit eaf8e43

Browse files
Feat/separate configs (#10)
* fix to typescript-eslint plugin not being declared as dependency * bump version to 0.1.3 * fix to typescript-eslint plugin not being declared as dependency * added separated configs for JavaScript and TypeScript * use base config in the project * added @dipcode/prettier-config as prettierrc base * added version 0.2.0 to changelog
1 parent 4540528 commit eaf8e43

File tree

8 files changed

+97
-53
lines changed

8 files changed

+97
-53
lines changed

.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const config = require('./src/config');
2+
3+
module.exports = {
4+
...config,
5+
};

.eslintrc.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [v0.1.3] - 2024-01-19
8+
## [v0.2.0] - 2024-01-23
99

10-
### Fixed
10+
### Changed
1111

12-
- changelog version links
13-
- `typescript-eslint` plugin not being declared as dependency
12+
- Default export is now JavaScript eslint config.
1413

1514
### Added
1615

16+
- Different configuration files to JavaScript and TypeScript.
1717
- `eslint-plugin-import` as dependency
1818

19+
### Fixed
20+
21+
- changelog version links
22+
- `typescript-eslint` plugin not being declared as dependency
23+
1924
## [v0.1.2] - 2024-01-17
2025

2126
### Fixed
@@ -33,7 +38,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3338

3439
- First release
3540

36-
[v0.1.3]: https://www.npmjs.com/package/@dipcode/eslint-config/v/0.1.3
41+
[v0.2.0]: https://www.npmjs.com/package/@dipcode/eslint-config/v/0.2.0
3742
[v0.1.2]: https://www.npmjs.com/package/@dipcode/eslint-config/v/0.1.2
3843
[v0.1.1]: https://www.npmjs.com/package/@dipcode/eslint-config/v/0.1.1
3944
[v0.1.0]: https://www.npmjs.com/package/@dipcode/eslint-config/v/0.1.0

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,35 @@
99

1010
The package provides Dipcode's `.eslintrc` as an extensible shared config.
1111

12-
1. Run `npm install --save-dev @dipcode/eslint-config`
13-
2. Add `"extends": "@dipcode/eslint-config"` to your `.eslintrc.json`
12+
Install the config
13+
14+
```sh
15+
npm install --save-dev @dipcode/eslint-config
16+
```
17+
18+
Then configure eslint to use the configuration.
19+
20+
### For JavaScript projects
21+
22+
`.eslintrc.json`
23+
24+
```json
25+
{
26+
"root": true,
27+
"extends": "@dipcode/eslint-config"
28+
}
29+
```
30+
31+
### For TypeScript projects
32+
33+
`.eslintrc.json`
34+
35+
```json
36+
{
37+
"root": true,
38+
"extends": "@dipcode/eslint-config/typescript"
39+
}
40+
```
1441

1542
## Links
1643

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dipcode/eslint-config",
3-
"version": "0.1.3",
3+
"version": "0.2.0",
44
"description": "Shareable ESLint config for Dipcode.",
55
"main": "./src/config.js",
66
"scripts": {
@@ -28,7 +28,14 @@
2828
"url": "https://github.com/dipcode-software/eslint-config-dipcode/issues"
2929
},
3030
"homepage": "https://github.com/dipcode-software/eslint-config-dipcode#readme",
31-
"exports": "./src/config.js",
31+
"exports": {
32+
".": "./src/config.js",
33+
"./typescript": "./src/typescript.js"
34+
},
35+
"files": [
36+
"src/config.js",
37+
"src/typescript.js"
38+
],
3239
"devDependencies": {
3340
"@dipcode/prettier-config": "0.1.0",
3441
"husky": "8.0.3",

src/config.js

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,26 @@
11
'use strict';
22

33
module.exports = {
4-
env: {
5-
browser: true,
6-
es2022: true,
7-
},
4+
env: { browser: true, es2022: true, commonjs: true },
85
extends: [
96
'eslint:recommended',
10-
'plugin:@typescript-eslint/recommended',
11-
'plugin:jsdoc/recommended-typescript-error',
127
'plugin:import/recommended',
13-
'plugin:import/typescript',
148
'plugin:promise/recommended',
159
// This must be the last
1610
'plugin:prettier/recommended',
1711
],
18-
plugins: ['@typescript-eslint', 'simple-import-sort', 'jsdoc'],
19-
parser: '@typescript-eslint/parser',
20-
parserOptions: { project: 'tsconfig.json', sourceType: 'module' },
12+
plugins: ['simple-import-sort', 'jsdoc'],
2113
rules: {
22-
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description' }],
14+
'camelcase': 'error',
2315
'simple-import-sort/imports': 'error',
2416
'simple-import-sort/exports': 'error',
2517
'no-console': ['error', { allow: ['warn', 'error'] }],
26-
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
27-
'import/extensions': [
28-
2,
29-
'always',
30-
{
31-
ignorePackages: true,
32-
pattern: {
33-
js: 'never',
34-
ts: 'never',
35-
tsx: 'never',
36-
},
37-
},
38-
],
18+
'import/extensions': [2, 'always', { ignorePackages: true, pattern: { js: 'never' } }],
3919
},
4020
ignorePatterns: ['node_modules'],
4121
settings: {
42-
'import/parsers': {
43-
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
44-
},
45-
'import/resolver': {
46-
node: {
47-
extensions: ['.js', '.json', '.ts', '.tsx', '.d.ts'],
48-
},
49-
},
50-
'import/extensions': ['.js', '.mjs', '.ts', '.tsx', '.d.ts'],
22+
'import/resolver': { node: { extensions: ['.js', '.json'] } },
23+
'import/extensions': ['.js', '.mjs'],
5124
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
5225
},
5326
overrides: [{ files: ['*.ts', '*.tsx'], rules: { 'import/named': 'off', 'import/no-unresolved': 'off' } }],

src/typescript.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
const base = require('./config');
4+
5+
module.exports = {
6+
env: { ...base.env },
7+
extends: [
8+
'eslint:recommended',
9+
'plugin:@typescript-eslint/recommended',
10+
'plugin:jsdoc/recommended-typescript-error',
11+
'plugin:import/recommended',
12+
'plugin:import/typescript',
13+
'plugin:promise/recommended',
14+
// This must be the last line
15+
'plugin:prettier/recommended',
16+
],
17+
plugins: ['@typescript-eslint', ...base.plugins],
18+
parser: '@typescript-eslint/parser',
19+
parserOptions: { project: './tsconfig.json', sourceType: 'module' },
20+
rules: {
21+
...base.rules,
22+
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-expect-error': 'allow-with-description' }],
23+
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
24+
'import/extensions': [2, 'always', { ignorePackages: true, pattern: { js: 'never', ts: 'never', tsx: 'never' } }],
25+
},
26+
settings: {
27+
...base.settings,
28+
'import/parsers': { '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'] },
29+
'import/resolver': {
30+
node: { extensions: [...base.settings['import/resolver'].node.extensions, '.ts', '.tsx', '.d.ts'] },
31+
},
32+
'import/extensions': [...base.settings['import/extensions'], '.ts', '.tsx', '.d.ts'],
33+
},
34+
overrides: [{ files: ['*.ts', '*.tsx'], rules: { 'import/named': 'off', 'import/no-unresolved': 'off' } }],
35+
};

0 commit comments

Comments
 (0)