@plugjs/eslint-plugin 0.3.42 → 0.4.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/NOTICE.md CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2022 Juit GmbH
1
+ # Copyright 2022-2025 Juit GmbH
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -4,14 +4,62 @@ PlugJS ESLint (v9) Shared Configuration
4
4
  This package exports simple configurations for linting our projects. It's the
5
5
  easiest way to actually share some configs and plugins.
6
6
 
7
- Just add in your `eslint.config.mjs` something similar to:
7
+ Just create a new `eslint.config.mjs` file following this template, your mileage
8
+ might vary, and according to your specific needs you might need to add/remove
9
+ stuff to fit your project:
8
10
 
9
11
  ```javascript
10
12
  import configurations from '@plugjs/eslint-plugin'
11
13
 
12
14
  export default [
13
15
  ...configurations,
14
- // any other configuration you might want to add for your project...
16
+
17
+ // ===== DEFINE THE LOCATION OF OUR TSCONFIG.JSON FILES ======================
18
+ {
19
+ languageOptions: {
20
+ parserOptions: {
21
+ createDefaultProgram: false,
22
+ project: [
23
+ './tsconfig.json',
24
+ './test/tsconfig.json',
25
+ ],
26
+ },
27
+ },
28
+ },
29
+
30
+ // ===== ENSURE THAT OUR MAIN FILES DEPEND ONLY ON PROPER DEPENDENCIES =======
31
+ {
32
+ files: [ 'src/**' ],
33
+ rules: {
34
+ // Turn _ON_ dependencies checks only for sources
35
+ 'import-x/no-extraneous-dependencies': [ 'error', {
36
+ 'devDependencies': true,
37
+ 'peerDependencies': true,
38
+ 'optionalDependencies': true,
39
+ 'bundledDependencies': false,
40
+ } ],
41
+ },
42
+ },
43
+
44
+ // ===== PROJECT LOCAL RULES =================================================
45
+ // Add any extra rule not tied to a specific "files" pattern here, e.g.:
46
+ // {
47
+ // rules: {
48
+ // 'camelcase': 'off',
49
+ // },
50
+ // },
51
+
52
+ // ===== IGNORED FILES =======================================================
53
+ // REMEMBER! Ignores *must* be in its own configuration, they can not coexist
54
+ // with "rules", "languageOptions", "files", ... or anything else, otherwise
55
+ // ESLint will blaantly ignore the ignore files!
56
+ {
57
+ ignores: [
58
+ 'coverage/',
59
+ 'dist/',
60
+ 'node_modules/',
61
+ ],
62
+ },
15
63
  ]
16
64
  ```
17
65
 
@@ -37,17 +85,6 @@ This includes a number of configurations:
37
85
  * `typescript-eslint/recommended`: recommended config for TypeScript
38
86
  * `plugjs-typescript`: our rules overriding `typescript-eslint/recommended`.
39
87
 
40
- Notes on building
41
- -----------------
42
-
43
- During this transitional period (ESLint from v8 to v9, and TypeScript ESLint
44
- from v7 to v8) a number of plugins, even if they are working, are specifying
45
- wrong/old dependencies in their packages.
46
-
47
- For those plugins, we bundle them up and ship them with this plugin, and
48
- hopefully we'll be able to un-bundle them as the various packages move in their
49
- transitions.
50
-
51
88
  Legal Stuff
52
89
  -----------
53
90
 
package/check.mjs ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+
3
+ /* eslint-disable no-console */
4
+ import { ESLint } from 'eslint'
5
+
6
+ /** @type Record<string, string[]> */
7
+ const deprecated = {}
8
+
9
+ // Pretty colors
10
+ const ylw = '\u001b[38;5;220m' // yellow
11
+ const grn = '\u001b[38;5;76m' // greenish
12
+ const rst = '\u001b[0m' // reset
13
+ // Running in GitHub Actions?
14
+ const gh = process.env.GITHUB_ACTIONS === 'true'
15
+
16
+ // Create a new ESLint
17
+ const eslint = new ESLint()
18
+
19
+ // Fake lint some sources (JS, TS, ...) to get the deprecated rules
20
+ for (const f of [ 'x.js', 'x.mjs', 'x.cjs', 'x.ts', 'x.cts', 'x.mts' ]) {
21
+ const results = await eslint.lintText('var foo="bar";', { filePath: f })
22
+ for (const result of results) {
23
+ for (const rule of result.usedDeprecatedRules) {
24
+ deprecated[rule.ruleId] = rule.replacedBy
25
+ }
26
+ }
27
+ }
28
+
29
+ // Print the deprecated rules in order
30
+ const deprecations = Object.entries(deprecated)
31
+ if (deprecations.length !== 0) {
32
+ deprecations
33
+ .sort(([ a ], [ b ]) => a.localeCompare(b))
34
+ .forEach(([ rule, replacement ]) => {
35
+ if (replacement.length) {
36
+ console.log(`Rule "${ylw}${rule}${rst}" deprecated and replaced by "${grn}${replacement.join(`${rst}", "${grn}`)}${rst}"`)
37
+ if (gh) console.log(`::warning::Rule "${rule}" deprecated and replaced by "${replacement.join(', ')}"`)
38
+ } else {
39
+ console.log(`Rule "${ylw}${rule}${rst}" deprecated without replacement`)
40
+ if (gh) console.log(`::warning::Rule "${rule}" deprecated without replacement`)
41
+ }
42
+ })
43
+ } else {
44
+ console.log(`${grn}Success:${rst} no deprecated rules found!`)
45
+ }
package/package.json CHANGED
@@ -1,23 +1,26 @@
1
1
  {
2
2
  "name": "@plugjs/eslint-plugin",
3
- "version": "0.3.42",
3
+ "version": "0.4.0",
4
4
  "description": "Shared ESLint configurations and extras",
5
5
  "main": "./index.mjs",
6
6
  "type": "module",
7
7
  "author": "Team Juit <developers@juit.com>",
8
8
  "license": "Apache-2.0",
9
+ "bin": {
10
+ "eslint-check-deprecated-rules": "./check.mjs"
11
+ },
9
12
  "scripts": {
10
13
  "build": "node check.mjs && eslint"
11
14
  },
12
15
  "dependencies": {
13
16
  "@eslint/js": "^9.34.0",
14
- "@stylistic/eslint-plugin": "^5.2.3",
17
+ "@stylistic/eslint-plugin": "^5.3.1",
15
18
  "eslint-import-resolver-node": "^0.3.9",
16
19
  "eslint-import-resolver-typescript": "^4.4.4",
17
20
  "eslint-plugin-import-x": "^4.16.1",
18
21
  "eslint-plugin-unicorn": "^60.0.0",
19
22
  "globals": "^16.3.0",
20
- "typescript-eslint": "^8.41.0"
23
+ "typescript-eslint": "^8.42.0"
21
24
  },
22
25
  "devDependencies": {
23
26
  "eslint": "^9.34.0"