@plugjs/eslint-plugin 0.2.4 → 0.2.6
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/configs/javascript.mjs +28 -2
- package/eslint.config.mjs +12 -39
- package/index.mjs +43 -0
- package/package.json +22 -8
package/configs/javascript.mjs
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
/** Basic extra rules for JavaScript sources. */
|
|
2
|
+
import process from 'node:process'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import fs from 'node:fs'
|
|
5
|
+
|
|
6
|
+
import globals from 'globals'
|
|
7
|
+
|
|
8
|
+
function findModuleType(directory) {
|
|
9
|
+
const file = path.join(directory, 'package.json')
|
|
10
|
+
try {
|
|
11
|
+
const data = JSON.parse(fs.readFileSync(file, 'utf-8'))
|
|
12
|
+
return data.type || 'commonjs'
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (error.code !== 'ENOENT') {
|
|
15
|
+
throw new Error(`Error reading "${file}"`, { cause: error })
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const parent = path.dirname(directory)
|
|
19
|
+
if (parent === directory) return 'commonjs'
|
|
20
|
+
return findModuleType(parent)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const moduleType = findModuleType(process.cwd())
|
|
25
|
+
|
|
2
26
|
export const javascript = {
|
|
3
27
|
name: 'plugjs-javascript',
|
|
4
28
|
|
|
@@ -21,10 +45,11 @@ export const javascript = {
|
|
|
21
45
|
export const javascriptCommonJs = {
|
|
22
46
|
name: 'plugjs-javascript-cjs',
|
|
23
47
|
|
|
24
|
-
files: [ '
|
|
48
|
+
files: moduleType === 'commonjs' ? [ '**/*.cjs', '**/*.js' ] : [ '**/*.cjs' ],
|
|
25
49
|
|
|
26
50
|
languageOptions: {
|
|
27
51
|
sourceType: 'commonjs',
|
|
52
|
+
globals: globals.node,
|
|
28
53
|
},
|
|
29
54
|
}
|
|
30
55
|
|
|
@@ -32,10 +57,11 @@ export const javascriptCommonJs = {
|
|
|
32
57
|
export const javascriptModule = {
|
|
33
58
|
name: 'plugjs-javascript-esm',
|
|
34
59
|
|
|
35
|
-
files: [ '
|
|
60
|
+
files: moduleType === 'module' ? [ '**/*.mjs', '**/*.js' ] : [ '**/*.mjs' ],
|
|
36
61
|
|
|
37
62
|
languageOptions: {
|
|
38
63
|
sourceType: 'module',
|
|
64
|
+
globals: globals.nodeBuiltin,
|
|
39
65
|
},
|
|
40
66
|
}
|
|
41
67
|
|
package/eslint.config.mjs
CHANGED
|
@@ -1,43 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import configurations from './index.mjs'
|
|
2
2
|
|
|
3
|
-
import basic from './configs/basic.mjs'
|
|
4
|
-
import javascript from './configs/javascript.mjs'
|
|
5
|
-
import typescript from './configs/typescript.mjs'
|
|
6
|
-
|
|
7
|
-
export * from './configs/basic.mjs'
|
|
8
|
-
export * from './configs/javascript.mjs'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Base `ESLint` configuration for PlugJS.
|
|
12
|
-
*
|
|
13
|
-
* This includes a number of configurations:
|
|
14
|
-
*
|
|
15
|
-
* * `eslint-recommended`: recommended JavaScript config from ESLint.
|
|
16
|
-
*
|
|
17
|
-
* * `plugjs-base`: basic configuration of ESLint rules.
|
|
18
|
-
* * `plugjs-stylistic`: style shared between JavaScript and TypeScript.
|
|
19
|
-
* * `plugjs-unicorn`: extra niceties from the ESLint Unicorn plugin.
|
|
20
|
-
* * `plugjs-importx`: defines the style of our imports.
|
|
21
|
-
*
|
|
22
|
-
* * `plugjs-javascript`: basic extra rules for JavaScript sources.
|
|
23
|
-
* * `plugjs-javascript-cjs`: marks `*.cjs` files as `commonjs`.
|
|
24
|
-
* * `plugjs-javascript-mjs`: marks `*.mjs` files as `module`.
|
|
25
|
-
*
|
|
26
|
-
* * `typescript-eslint/recommended`: imports all the configurations from
|
|
27
|
-
* TypeScript ESlint recommended, but restrict them to operate only on
|
|
28
|
-
* `.ts`, `.cts`, and `.mts` files. This *should* include:
|
|
29
|
-
* * `typescript-eslint/base`: basic parser configuration.
|
|
30
|
-
* * `typescript-eslint/eslint-recommended`: disable ESLint rules conflicting
|
|
31
|
-
* with TypeScript.
|
|
32
|
-
* * `typescript-eslint/recommended`: recommended config for TypeScript
|
|
33
|
-
* * `plugjs-typescript`: our rules overriding `typescript-eslint/recommended`.
|
|
34
|
-
*/
|
|
35
3
|
export default [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
4
|
+
...configurations,
|
|
5
|
+
|
|
6
|
+
// ===== IGNORED FILES =======================================================
|
|
7
|
+
// REMEMBER! Ignores *must* be in its own configuration, they can not coexist
|
|
8
|
+
// with "rules", "languageOptions", "files", ... or anything else, otherwise
|
|
9
|
+
// ESLint will blaantly ignore the ignore files!
|
|
10
|
+
{
|
|
11
|
+
ignores: [
|
|
12
|
+
'bundles/',
|
|
13
|
+
'node_modules/',
|
|
14
|
+
],
|
|
39
15
|
},
|
|
40
|
-
...basic,
|
|
41
|
-
...javascript,
|
|
42
|
-
...typescript,
|
|
43
16
|
]
|
package/index.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
|
|
3
|
+
import basic from './configs/basic.mjs'
|
|
4
|
+
import javascript from './configs/javascript.mjs'
|
|
5
|
+
import typescript from './configs/typescript.mjs'
|
|
6
|
+
|
|
7
|
+
export * from './configs/basic.mjs'
|
|
8
|
+
export * from './configs/javascript.mjs'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Base `ESLint` configuration for PlugJS.
|
|
12
|
+
*
|
|
13
|
+
* This includes a number of configurations:
|
|
14
|
+
*
|
|
15
|
+
* * `eslint-recommended`: recommended JavaScript config from ESLint.
|
|
16
|
+
*
|
|
17
|
+
* * `plugjs-base`: basic configuration of ESLint rules.
|
|
18
|
+
* * `plugjs-stylistic`: style shared between JavaScript and TypeScript.
|
|
19
|
+
* * `plugjs-unicorn`: extra niceties from the ESLint Unicorn plugin.
|
|
20
|
+
* * `plugjs-importx`: defines the style of our imports.
|
|
21
|
+
*
|
|
22
|
+
* * `plugjs-javascript`: basic extra rules for JavaScript sources.
|
|
23
|
+
* * `plugjs-javascript-cjs`: marks `*.cjs` files as `commonjs`.
|
|
24
|
+
* * `plugjs-javascript-mjs`: marks `*.mjs` files as `module`.
|
|
25
|
+
*
|
|
26
|
+
* * `typescript-eslint/recommended`: imports all the configurations from
|
|
27
|
+
* TypeScript ESlint recommended, but restrict them to operate only on
|
|
28
|
+
* `.ts`, `.cts`, and `.mts` files. This *should* include:
|
|
29
|
+
* * `typescript-eslint/base`: basic parser configuration.
|
|
30
|
+
* * `typescript-eslint/eslint-recommended`: disable ESLint rules conflicting
|
|
31
|
+
* with TypeScript.
|
|
32
|
+
* * `typescript-eslint/recommended`: recommended config for TypeScript
|
|
33
|
+
* * `plugjs-typescript`: our rules overriding `typescript-eslint/recommended`.
|
|
34
|
+
*/
|
|
35
|
+
export default [
|
|
36
|
+
{ // give a name to this config before we go completely nuts!
|
|
37
|
+
name: 'eslint/js/recommended',
|
|
38
|
+
...js.configs.recommended,
|
|
39
|
+
},
|
|
40
|
+
...basic,
|
|
41
|
+
...javascript,
|
|
42
|
+
...typescript,
|
|
43
|
+
]
|
package/package.json
CHANGED
|
@@ -1,27 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugjs/eslint-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Shared ESLint configurations and extras",
|
|
5
|
-
"main": "./
|
|
5
|
+
"main": "./index.mjs",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Team Juit <developers@juit.com>",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "eslint
|
|
10
|
+
"build": "eslint"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"eslint": "^9.7.0"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"*.md",
|
|
17
|
-
"eslint.config.mjs",
|
|
18
17
|
"bundles/",
|
|
19
|
-
"configs/"
|
|
18
|
+
"configs/",
|
|
19
|
+
"eslint.config.mjs",
|
|
20
|
+
"index.mjs"
|
|
20
21
|
],
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+ssh://git@github.com/plugjs/eslint-plugin.git"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"validation",
|
|
28
|
+
"typescript",
|
|
29
|
+
"javascript"
|
|
30
|
+
],
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/plugjs/eslint-plugin/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/plugjs/eslint-plugin#readme",
|
|
21
35
|
"dependencies": {
|
|
22
36
|
"@eslint/js": "9.7.0",
|
|
23
37
|
"@rtsao/scc": "1.1.0",
|
|
24
|
-
"@typescript-eslint/utils": "8.0.0-alpha.
|
|
38
|
+
"@typescript-eslint/utils": "8.0.0-alpha.45",
|
|
25
39
|
"debug": "4.3.5",
|
|
26
40
|
"doctrine": "2.1.0",
|
|
27
41
|
"enhanced-resolve": "5.17.0",
|
|
@@ -32,7 +46,7 @@
|
|
|
32
46
|
"espree": "10.1.0",
|
|
33
47
|
"estraverse": "5.3.0",
|
|
34
48
|
"fast-glob": "3.3.2",
|
|
35
|
-
"get-tsconfig": "4.7.
|
|
49
|
+
"get-tsconfig": "4.7.6",
|
|
36
50
|
"globals": "15.8.0",
|
|
37
51
|
"is-core-module": "2.15.0",
|
|
38
52
|
"is-glob": "4.0.3",
|
|
@@ -43,6 +57,6 @@
|
|
|
43
57
|
"stable-hash": "0.0.4",
|
|
44
58
|
"tslib": "2.6.3",
|
|
45
59
|
"typescript": "5.5.3",
|
|
46
|
-
"typescript-eslint": "8.0.0-alpha.
|
|
60
|
+
"typescript-eslint": "8.0.0-alpha.45"
|
|
47
61
|
}
|
|
48
62
|
}
|