@langri-sha/projen-eslint 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +52 -0
- package/CHANGELOG.md +21 -0
- package/lib/index.d.ts +32 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +45 -0
- package/lib/index.js.map +1 -0
- package/license +10 -0
- package/package.json +33 -0
- package/readme +37 -0
- package/src/index.ts +69 -0
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@langri-sha/projen-eslint",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Sat, 15 Jun 2024 09:06:45 GMT",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"tag": "@langri-sha/projen-eslint_v0.1.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "filip.dupanovic@gmail.com",
|
|
12
|
+
"package": "@langri-sha/projen-eslint",
|
|
13
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
14
|
+
"comment": "feat(projen): Reconfigure project expressions"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "filip.dupanovic@gmail.com",
|
|
18
|
+
"package": "@langri-sha/projen-eslint",
|
|
19
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
20
|
+
"comment": "feat(projen): Drop pinning peer dependencies"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "filip.dupanovic@gmail.com",
|
|
24
|
+
"package": "@langri-sha/projen-eslint",
|
|
25
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
26
|
+
"comment": "feat(project): Reconfigure NPM ignore patterns"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "filip.dupanovic@gmail.com",
|
|
30
|
+
"package": "@langri-sha/projen-eslint",
|
|
31
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
32
|
+
"comment": "feat(eslint): Add component for configuring ESLint"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "filip.dupanovic@gmail.com",
|
|
36
|
+
"package": "@langri-sha/projen-eslint",
|
|
37
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
38
|
+
"comment": "feat(project): Omit Node.js engine package defaults"
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"patch": [
|
|
42
|
+
{
|
|
43
|
+
"author": "email not defined",
|
|
44
|
+
"package": "@langri-sha/projen-eslint",
|
|
45
|
+
"commit": "7ac78ea2d172ae9e30f23d213752297fb8436a88",
|
|
46
|
+
"comment": "chore(deps): chore(deps): update dependency projen to v0.82.3"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Change Log - @langri-sha/projen-eslint
|
|
2
|
+
|
|
3
|
+
This log was last generated on Sat, 15 Jun 2024 09:06:45 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
<!-- Start content -->
|
|
6
|
+
|
|
7
|
+
## 0.1.0
|
|
8
|
+
|
|
9
|
+
Sat, 15 Jun 2024 09:06:45 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- feat(projen): Reconfigure project expressions (filip.dupanovic@gmail.com)
|
|
14
|
+
- feat(projen): Drop pinning peer dependencies (filip.dupanovic@gmail.com)
|
|
15
|
+
- feat(project): Reconfigure NPM ignore patterns (filip.dupanovic@gmail.com)
|
|
16
|
+
- feat(eslint): Add component for configuring ESLint (filip.dupanovic@gmail.com)
|
|
17
|
+
- feat(project): Omit Node.js engine package defaults (filip.dupanovic@gmail.com)
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- chore(deps): chore(deps): update dependency projen to v0.82.3 (email not defined)
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FileBase, IResolver, Project } from 'projen';
|
|
2
|
+
/**
|
|
3
|
+
* Options for configuring ESLint.
|
|
4
|
+
*/
|
|
5
|
+
export interface ESLintOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Name of the ESLint config module.
|
|
8
|
+
*
|
|
9
|
+
* @default 'eslint.config.js'
|
|
10
|
+
*/
|
|
11
|
+
filename?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Name of the ESLint configuration package to extend from.
|
|
14
|
+
*/
|
|
15
|
+
extends?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Ignore patterns.
|
|
18
|
+
*/
|
|
19
|
+
ignorePatterns?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Prettier configuration object.
|
|
22
|
+
*/
|
|
23
|
+
config?: any[];
|
|
24
|
+
}
|
|
25
|
+
export declare class ESLint extends FileBase {
|
|
26
|
+
#private;
|
|
27
|
+
config: any[];
|
|
28
|
+
ignorePatterns: string[];
|
|
29
|
+
constructor(project: Project, options?: ESLintOptions);
|
|
30
|
+
protected synthesizeContent(_: IResolver): string | undefined;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IAEzB;;OAEG;IAEH,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;CACf;AAED,qBAAa,MAAO,SAAQ,QAAQ;;IAGlC,MAAM,EAAE,GAAG,EAAE,CAAA;IACb,cAAc,EAAE,MAAM,EAAE,CAAA;gBAEZ,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,aAAkB;cAatC,iBAAiB,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS;CAkBvE"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ESLint_extends;
|
|
13
|
+
import serialize from 'serialize-javascript';
|
|
14
|
+
import { FileBase } from 'projen';
|
|
15
|
+
export class ESLint extends FileBase {
|
|
16
|
+
constructor(project, options = {}) {
|
|
17
|
+
const filename = options.filename ?? 'eslint.config.js';
|
|
18
|
+
super(project, filename, {
|
|
19
|
+
readonly: true,
|
|
20
|
+
marker: true,
|
|
21
|
+
});
|
|
22
|
+
_ESLint_extends.set(this, void 0);
|
|
23
|
+
__classPrivateFieldSet(this, _ESLint_extends, options.extends, "f");
|
|
24
|
+
this.config = options.config ?? [];
|
|
25
|
+
this.ignorePatterns = options.ignorePatterns ?? [];
|
|
26
|
+
}
|
|
27
|
+
synthesizeContent(_) {
|
|
28
|
+
const config = [
|
|
29
|
+
...(this.ignorePatterns.length
|
|
30
|
+
? [
|
|
31
|
+
{
|
|
32
|
+
ignores: this.ignorePatterns,
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
: []),
|
|
36
|
+
...this.config,
|
|
37
|
+
];
|
|
38
|
+
const serialized = serialize(config, {
|
|
39
|
+
unsafe: true,
|
|
40
|
+
});
|
|
41
|
+
return `${__classPrivateFieldGet(this, _ESLint_extends, "f") ? `import defaults from '${__classPrivateFieldGet(this, _ESLint_extends, "f")}'\n\n` : ''}export default ${__classPrivateFieldGet(this, _ESLint_extends, "f") ? '[...defaults, ' : '['}${serialized.slice(1)}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
_ESLint_extends = new WeakMap();
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,SAAS,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAsB,MAAM,QAAQ,CAAA;AA8BrD,MAAM,OAAO,MAAO,SAAQ,QAAQ;IAMlC,YAAY,OAAgB,EAAE,UAAyB,EAAE;QACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,kBAAkB,CAAA;QAEvD,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE;YACvB,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI;SACb,CAAC,CAAA;QAXJ,kCAAiB;QAaf,uBAAA,IAAI,mBAAY,OAAO,CAAC,OAAO,MAAA,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAA;QAClC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,CAAA;IACpD,CAAC;IAEkB,iBAAiB,CAAC,CAAY;QAC/C,MAAM,MAAM,GAAG;YACb,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM;gBAC5B,CAAC,CAAC;oBACE;wBACE,OAAO,EAAE,IAAI,CAAC,cAAc;qBAC7B;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,GAAG,IAAI,CAAC,MAAM;SACf,CAAA;QAED,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE;YACnC,MAAM,EAAE,IAAI;SACb,CAAC,CAAA;QAEF,OAAO,GAAG,uBAAA,IAAI,uBAAS,CAAC,CAAC,CAAC,yBAAyB,uBAAA,IAAI,uBAAS,OAAO,CAAC,CAAC,CAAC,EAAE,kBAAkB,uBAAA,IAAI,uBAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9J,CAAC;CACF"}
|
package/license
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2024 Filip Dupanović <filip.dupanovic@gmail.com> (https://langri-sha.com)
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@langri-sha/projen-eslint",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Filip Dupanović",
|
|
7
|
+
"email": "filip.dupanovic@gmail.com",
|
|
8
|
+
"url": "https://langri-sha.com",
|
|
9
|
+
"organization": false
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "lib/index.js",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"prepublishOnly": "rm -rf lib; tsc --project tsconfig.build.json"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"serialize-javascript": "6.0.2"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@langri-sha/jest-test": "0.8.0",
|
|
21
|
+
"@langri-sha/tsconfig": "0.10.0",
|
|
22
|
+
"@types/serialize-javascript": "5.0.4"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"eslint": "^9.0.0",
|
|
26
|
+
"projen": "^0.82.0"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"//": "~~ Generated by projen. To modify, edit .projenrc.mts and run \"npx projen\".",
|
|
32
|
+
"types": "lib/index.d.ts"
|
|
33
|
+
}
|
package/readme
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @langri-sha/projen-eslint
|
|
2
|
+
|
|
3
|
+
A [projen] component for configuring [ESLint].
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Install dependencies:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install -D eslint @langri-sha/projen-eslint
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then, create an `ESLint` component for your project:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { Project } from 'projen'
|
|
17
|
+
import { ESLint } from '@langri-sha/projen-eslint'
|
|
18
|
+
|
|
19
|
+
const project = new Project({
|
|
20
|
+
name: 'my-project',
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
new ESLint(project, {
|
|
24
|
+
ignorePatterns: ['.*'],
|
|
25
|
+
extends: '@langri-sha/eslint-config'
|
|
26
|
+
config: [
|
|
27
|
+
{
|
|
28
|
+
rules: {
|
|
29
|
+
'unicorn/prefer-node-modules': 'error'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
[eslint]: https://eslint.org/docs/latest/
|
|
37
|
+
[projen]: https://projen.io/
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import serialize from 'serialize-javascript'
|
|
2
|
+
import { FileBase, IResolver, Project } from 'projen'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options for configuring ESLint.
|
|
6
|
+
*/
|
|
7
|
+
export interface ESLintOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Name of the ESLint config module.
|
|
10
|
+
*
|
|
11
|
+
* @default 'eslint.config.js'
|
|
12
|
+
*/
|
|
13
|
+
filename?: string
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Name of the ESLint configuration package to extend from.
|
|
17
|
+
*/
|
|
18
|
+
extends?: string
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Ignore patterns.
|
|
22
|
+
*/
|
|
23
|
+
ignorePatterns?: string[]
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Prettier configuration object.
|
|
27
|
+
*/
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
config?: any[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class ESLint extends FileBase {
|
|
33
|
+
#extends?: string
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
config: any[]
|
|
36
|
+
ignorePatterns: string[]
|
|
37
|
+
|
|
38
|
+
constructor(project: Project, options: ESLintOptions = {}) {
|
|
39
|
+
const filename = options.filename ?? 'eslint.config.js'
|
|
40
|
+
|
|
41
|
+
super(project, filename, {
|
|
42
|
+
readonly: true,
|
|
43
|
+
marker: true,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
this.#extends = options.extends
|
|
47
|
+
this.config = options.config ?? []
|
|
48
|
+
this.ignorePatterns = options.ignorePatterns ?? []
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected override synthesizeContent(_: IResolver): string | undefined {
|
|
52
|
+
const config = [
|
|
53
|
+
...(this.ignorePatterns.length
|
|
54
|
+
? [
|
|
55
|
+
{
|
|
56
|
+
ignores: this.ignorePatterns,
|
|
57
|
+
},
|
|
58
|
+
]
|
|
59
|
+
: []),
|
|
60
|
+
...this.config,
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
const serialized = serialize(config, {
|
|
64
|
+
unsafe: true,
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
return `${this.#extends ? `import defaults from '${this.#extends}'\n\n` : ''}export default ${this.#extends ? '[...defaults, ' : '['}${serialized.slice(1)}`
|
|
68
|
+
}
|
|
69
|
+
}
|