@jeffcaradona/eslint-plugin-eta 0.2.1 → 0.2.3
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/LICENSE +4 -19
- package/README.md +15 -17
- package/lib/processors/eta.js +6 -9
- package/package.json +10 -5
- package/sonar-project.properties +15 -0
- package/.travis.yml +0 -14
- package/ETA_V4_API_RESEARCH.md +0 -149
- package/eslint.config.js +0 -19
- package/jeffcaradona-eslint-plugin-eta-0.2.1.tgz +0 -0
- package/upgrade_path.md +0 -41
package/LICENSE
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
+
Copyright 2025 Jeff Caradona <jeffcaradona@gmail.com>
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
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:
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
of this software ,and associated documentation files (the "Software"), to deal
|
|
8
|
-
in the Software without restriction, including without limitation the rights
|
|
9
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
furnished to do so subject to the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
SOFTWARE.
|
|
7
|
+
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/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# eslint-plugin-eta
|
|
2
|
+
An ESLint plugin so you can lint Eta template files (forked from <https://github.com/bgub/eslint-plugin-eta>) with so much assistance from GitHub Copilot.
|
|
2
3
|
|
|
3
4
|
<span align="center">
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[](https://coveralls.io/github/eta-dev/eslint-plugin-eta)
|
|
6
|
+
|
|
7
7
|
|
|
8
8
|
</span>
|
|
9
9
|
|
|
@@ -12,22 +12,20 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
### Installation
|
|
15
|
-
Run `npm install --save-dev eslint-plugin-eta` to install this ESLint plugin.
|
|
15
|
+
Run `npm install --save-dev @jeffcaradona/eslint-plugin-eta` to install this ESLint plugin.
|
|
16
16
|
|
|
17
17
|
### Usage
|
|
18
|
-
Add this to your
|
|
18
|
+
Add this to your `eslint.config.js`:
|
|
19
19
|
```javascript
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
...
|
|
32
|
-
}
|
|
20
|
+
import eta from '@jeffcaradona/eslint-plugin-eta'
|
|
21
|
+
|
|
22
|
+
export default [
|
|
23
|
+
{
|
|
24
|
+
files: ['**/*.eta'],
|
|
25
|
+
plugins: {
|
|
26
|
+
eta
|
|
27
|
+
},
|
|
28
|
+
processor: 'eta/eta'
|
|
29
|
+
}
|
|
30
|
+
]
|
|
33
31
|
```
|
package/lib/processors/eta.js
CHANGED
|
@@ -12,18 +12,15 @@ export default {
|
|
|
12
12
|
})
|
|
13
13
|
let result = eta.parse(text)
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
(res) => res.t === 'r' || res.t === 'i' || res.t === 'e'
|
|
17
|
-
|
|
15
|
+
const text_content = result
|
|
16
|
+
.filter((res) => res.t === 'r' || res.t === 'i' || res.t === 'e')
|
|
17
|
+
.map((res) => String(res.val))
|
|
18
|
+
.join('\n')
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
result = result.join('\n')
|
|
22
|
-
|
|
23
|
-
return [{ text: result, filename: _filename }]
|
|
20
|
+
return [{ text: text_content, filename: _filename }]
|
|
24
21
|
},
|
|
25
22
|
|
|
26
23
|
postprocess: (messages, _filename) => {
|
|
27
|
-
return
|
|
24
|
+
return messages.flat()
|
|
28
25
|
}
|
|
29
26
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffcaradona/eslint-plugin-eta",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "An ESLint plugin so you can lint Eta template files",
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"description": "An ESLint plugin so you can lint Eta template files (forked from bgub/eslint-plugin-eta)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -16,11 +16,16 @@
|
|
|
16
16
|
"eslint",
|
|
17
17
|
"eslintplugin"
|
|
18
18
|
],
|
|
19
|
-
"author": "jeffcaradona",
|
|
19
|
+
"author": "jeffcaradona <jeffcaradona@gmail.com>",
|
|
20
20
|
"contributors": [
|
|
21
|
-
"
|
|
21
|
+
"Ben Gubler (Original Author)"
|
|
22
22
|
],
|
|
23
23
|
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/jeffcaradona/eslint-plugin-eta.git"
|
|
27
|
+
|
|
28
|
+
},
|
|
24
29
|
"peerDependencies": {
|
|
25
30
|
"eslint": ">=9 <10",
|
|
26
31
|
"eta": ">=1.0.0 <5.0.0"
|
|
@@ -55,4 +60,4 @@
|
|
|
55
60
|
"/test/"
|
|
56
61
|
]
|
|
57
62
|
}
|
|
58
|
-
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
sonar.projectKey=jeffcaradona_eslint-plugin-eta
|
|
2
|
+
sonar.organization=xbe90seup2ltm6gwmugkq
|
|
3
|
+
|
|
4
|
+
# Project settings
|
|
5
|
+
sonar.projectName=eslint-plugin-eta
|
|
6
|
+
sonar.projectVersion=0.2.2
|
|
7
|
+
sonar.sourceEncoding=UTF-8
|
|
8
|
+
|
|
9
|
+
# Source code
|
|
10
|
+
sonar.sources=lib
|
|
11
|
+
sonar.tests=test
|
|
12
|
+
sonar.javascript.lcov.reportPaths=coverage/lcov.info
|
|
13
|
+
|
|
14
|
+
# Coverage
|
|
15
|
+
sonar.coverage.exclusions=lib/**/index.js
|
package/.travis.yml
DELETED
package/ETA_V4_API_RESEARCH.md
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
# Eta v4.5.0 API Research Findings
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
Eta v4 is a significant rewrite. The current code uses `Eta.parse()` which is a static function on the old API. In v4, the API changed to an instance-based approach.
|
|
5
|
-
|
|
6
|
-
## 1. Parse Method Replacement
|
|
7
|
-
|
|
8
|
-
**Old API (v3):**
|
|
9
|
-
```javascript
|
|
10
|
-
const result = Eta.parse(text, config)
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
**New API (v4.5.0):**
|
|
14
|
-
```javascript
|
|
15
|
-
const eta = new Eta(config)
|
|
16
|
-
const result = eta.parse(text)
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
**Key Change:** `parse()` is now an **instance method**, not a static method. Config must be passed to the constructor.
|
|
20
|
-
|
|
21
|
-
### Source Evidence
|
|
22
|
-
From `src/internal.ts`:
|
|
23
|
-
```typescript
|
|
24
|
-
export class Eta {
|
|
25
|
-
constructor(customConfig?: Partial<EtaConfig>) {
|
|
26
|
-
if (customConfig) {
|
|
27
|
-
this.config = { ...defaultConfig, ...customConfig };
|
|
28
|
-
} else {
|
|
29
|
-
this.config = { ...defaultConfig };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
parse = parse; // parse is an instance method
|
|
34
|
-
compile = compile;
|
|
35
|
-
compileToString = compileToString;
|
|
36
|
-
// ... other methods
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## 2. Token Schema - UNCHANGED ✓
|
|
41
|
-
|
|
42
|
-
The token schema remains the same:
|
|
43
|
-
```typescript
|
|
44
|
-
export interface TemplateObject {
|
|
45
|
-
t: TagType; // Tag type: "r" (raw), "e" (exec), "i" (interpolate), "" (text)
|
|
46
|
-
val: string; // Token value/content
|
|
47
|
-
lineNo?: number; // Line number (optional, when debug: true)
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
**In v4, the schema uses `lineNo` instead of `line` for the debug property:**
|
|
52
|
-
- Old: `{t, val, line}`
|
|
53
|
-
- New: `{t, val, lineNo}`
|
|
54
|
-
|
|
55
|
-
Note: Current ESLint processor code doesn't use lineNo, so minimal change needed here.
|
|
56
|
-
|
|
57
|
-
## 3. Tag/Config Option Names - MOSTLY UNCHANGED ✓
|
|
58
|
-
|
|
59
|
-
The parsing configuration structure is preserved in v4:
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
// From src/config.ts
|
|
63
|
-
parse: {
|
|
64
|
-
exec: string; // Prefix for code execution (default: "")
|
|
65
|
-
interpolate: string; // Prefix for interpolation (default: "=")
|
|
66
|
-
raw: string; // Prefix for raw output (default: "~")
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
tags: [string, string]; // Delimiters (default: ["<%", "%>"])
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
**These are identical to v3 usage.** No changes needed for tag/delimiter configuration.
|
|
73
|
-
|
|
74
|
-
Additional relevant config options (same as v3):
|
|
75
|
-
- `debug`: boolean - enables `lineNo` in tokens
|
|
76
|
-
- `autoEscape`: boolean (default: true)
|
|
77
|
-
- `autoFilter`: boolean (default: false)
|
|
78
|
-
- `rmWhitespace`: boolean (default: false)
|
|
79
|
-
- `varName`: string (default: "it")
|
|
80
|
-
- `useWith`: boolean (default: false)
|
|
81
|
-
|
|
82
|
-
## 4. Main Export and Available Methods
|
|
83
|
-
|
|
84
|
-
**Eta class (v4.5.0) instance methods:**
|
|
85
|
-
|
|
86
|
-
Core methods:
|
|
87
|
-
- `parse(str)` → returns `Array<AstObject>` - Parses template string to AST
|
|
88
|
-
- `compile(str, options?)` → returns `TemplateFunction` - Compiles to function
|
|
89
|
-
- `compileToString(str, options?)` → returns `string` - Returns JS code as string
|
|
90
|
-
- `render(name, data, options?)` - Render from cache/file
|
|
91
|
-
- `renderAsync(name, data, options?)` - Async render
|
|
92
|
-
- `renderString(str, data, options?)` - Render inline string
|
|
93
|
-
- `renderStringAsync(str, data, options?)` - Async render inline
|
|
94
|
-
|
|
95
|
-
Configuration methods:
|
|
96
|
-
- `configure(customConfig)` - Update config on existing instance
|
|
97
|
-
- `withConfig(customConfig)` - Return new instance with config
|
|
98
|
-
|
|
99
|
-
Template management:
|
|
100
|
-
- `loadTemplate(name, template, options?)` - Cache a template function
|
|
101
|
-
|
|
102
|
-
## 5. How to Adapt the ESLint Processor
|
|
103
|
-
|
|
104
|
-
**Current code:**
|
|
105
|
-
```javascript
|
|
106
|
-
const Eta = require('eta')
|
|
107
|
-
|
|
108
|
-
module.exports = {
|
|
109
|
-
preprocess: (text, filename) => {
|
|
110
|
-
let result = Eta.parse(text, {
|
|
111
|
-
parse: { exec: '', interpolate: '=', raw: '~' },
|
|
112
|
-
tags: ['<%', '%>']
|
|
113
|
-
})
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
**Updated code:**
|
|
117
|
-
```javascript
|
|
118
|
-
const { Eta } = require('eta') // Import Eta class
|
|
119
|
-
|
|
120
|
-
module.exports = {
|
|
121
|
-
preprocess: (text, filename) => {
|
|
122
|
-
const eta = new Eta({ // Create instance with config
|
|
123
|
-
parse: { exec: '', interpolate: '=', raw: '~' },
|
|
124
|
-
tags: ['<%', '%>']
|
|
125
|
-
})
|
|
126
|
-
let result = eta.parse(text) // Call parse on instance
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
**Changes needed:**
|
|
130
|
-
1. `const Eta = require('eta')` → `const { Eta } = require('eta')`
|
|
131
|
-
2. `Eta.parse(text, config)` → Create instance then `eta.parse(text)`
|
|
132
|
-
3. Optional: Handle `lineNo` instead of `line` if used (not applicable to current code)
|
|
133
|
-
|
|
134
|
-
## Summary Table
|
|
135
|
-
|
|
136
|
-
| Aspect | Old (v3) | New (v4.5.0) | Status |
|
|
137
|
-
|--------|----------|--------------|--------|
|
|
138
|
-
| Parse API | `Eta.parse(str, config)` | `new Eta(config).parse(str)` | **CHANGED** |
|
|
139
|
-
| Import | `const Eta = require('eta')` | `const { Eta } = require('eta')` | **CHANGED** |
|
|
140
|
-
| Token schema | `{t, val, line}` | `{t, val, lineNo}` | ✓ Compatible |
|
|
141
|
-
| Tag config | `tags: ['<%', '%>']` | `tags: ['<%', '%>']` | ✓ Same |
|
|
142
|
-
| Parse options | `parse: {exec, interpolate, raw}` | `parse: {exec, interpolate, raw}` | ✓ Same |
|
|
143
|
-
| Token types | `r`, `e`, `i`, `` | `r`, `e`, `i`, `` | ✓ Same |
|
|
144
|
-
|
|
145
|
-
## Implementation Priority
|
|
146
|
-
|
|
147
|
-
**Critical:** Update parse call from static to instance method
|
|
148
|
-
**Low Priority:** Handle `lineNo` field (current code doesn't use it)
|
|
149
|
-
**Optional:** Use new instance methods like `renderString()` if needed
|
package/eslint.config.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import js from '@eslint/js'
|
|
2
|
-
import globals from 'globals'
|
|
3
|
-
|
|
4
|
-
export default [
|
|
5
|
-
js.configs.recommended,
|
|
6
|
-
{
|
|
7
|
-
languageOptions: {
|
|
8
|
-
ecmaVersion: 2020,
|
|
9
|
-
sourceType: 'module',
|
|
10
|
-
globals: {
|
|
11
|
-
...globals.node,
|
|
12
|
-
...globals.jest
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
rules: {
|
|
16
|
-
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
]
|
|
Binary file
|
package/upgrade_path.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# Upgrade Path (ESLint 9 target)
|
|
2
|
-
|
|
3
|
-
Target: move to ESLint 9.x (flat config support) while stepping dependencies through patch/minor before majors. Keep Node on a supported version for ESLint 9 (>=18.18.0; aim for 22.x as the long-term target, 20.x acceptable while upgrading).
|
|
4
|
-
|
|
5
|
-
## Order of operations
|
|
6
|
-
- Patch/minor only: coveralls, eslint-plugin-import, existing majors at latest patch.
|
|
7
|
-
|
|
8
|
-
- ESLint family to 9.x: migrate config to flat-config (or maintain legacy via eslint-compat if desired), upgrade eslint, eslint-plugin-node (or eslint-plugin-n), eslint-plugin-promise, eslint-plugin-standard, @typescript-eslint/eslint-plugin.
|
|
9
|
-
|
|
10
|
-
- Eta to chosen major (recommended 4.x after staged checks below).
|
|
11
|
-
- Tooling majors: jest, prettier, typescript.
|
|
12
|
-
- Final sweep: rerun lint/test/format, update peer ranges and docs.
|
|
13
|
-
|
|
14
|
-
## Component paths
|
|
15
|
-
|
|
16
|
-
### ESLint core and plugins
|
|
17
|
-
- eslint 7.11.0 → 7.32.0 (latest 7.x) → 8.x.latest → 9.x.latest. Migrate to flat config on the 9 jump; consider eslint-compat to bridge eslintrc if needed.
|
|
18
|
-
- eslint-plugin-import 2.22.1 → 2.32.0 (patch/minor only); re-run lint for new rules/options.
|
|
19
|
-
- eslint-plugin-promise 4.2.1 → 4.x.latest → 5.x → 6.x → 7.2.1; watch for rule defaults changing severity/options.
|
|
20
|
-
- eslint-plugin-standard 4.0.1 → 4.x.latest → 5.0.0; update any extended configs if rules moved.
|
|
21
|
-
- eslint-plugin-node 11.1.0 → 11.x.latest; consider migrating to eslint-plugin-n if/when rules move; ensure Node version map matches runtime.
|
|
22
|
-
- @typescript-eslint/eslint-plugin 4.5.0 → 4.x.latest → 5.x → 6.x → 7.x → 8.50.0; ensure parser version aligns with ESLint 9 support matrix.
|
|
23
|
-
- Peer ranges: set eslint to ">=9 <10" and align @typescript-eslint peer if required by chosen major.
|
|
24
|
-
|
|
25
|
-
### Eta processor
|
|
26
|
-
- Current usage: Eta.parse with options {parse: {exec:"", interpolate:"=", raw:"~"}, tags:["<%","%>"]}, filtering tokens where t ∈ {r,i,e} and using val strings.
|
|
27
|
-
- Path: 1.11.0 → 1.x.latest → 2.x → 3.x → 4.5.0.
|
|
28
|
-
- Checks per jump: confirm parse() signature and token schema (t/val/line), option names (tags, parse, autoEscape/includeLineNo) unchanged, and CommonJS require still supported; add/adjust tests that snapshot parse output for representative templates.
|
|
29
|
-
- If Eta becomes ESM-only, add an import shim (dynamic import or esm proxy) before moving on.
|
|
30
|
-
- Update peer range to match chosen Eta major once validated.
|
|
31
|
-
|
|
32
|
-
### Tooling and formatters
|
|
33
|
-
- jest 26.6.0 → 27.x.latest → 28.x.latest → 29.x.latest → 30.2.0; update fake timers config and watch ESM defaults if used. Until Jest is on 29+, keep a moduleNameMapper for `^node:(.*)$` → `$1`.
|
|
34
|
-
- prettier 2.1.2 → 2.8.8 → 3.7.4; expect formatting churn—run format after Prettier 3 bump and commit separately.
|
|
35
|
-
- typescript 4.0.3 → 4.9.5 → 5.9.3; adjust tsconfig lib/target as needed; ensure @typescript-eslint major matches.
|
|
36
|
-
- coveralls 3.1.0 → 3.1.1 (patch).
|
|
37
|
-
|
|
38
|
-
## Verification checkpoints
|
|
39
|
-
- After each stage, run: npm test, npm run lint, npm run format (post-Prettier 3) to isolate regressions.
|
|
40
|
-
- Add processor-focused tests to lock Eta.parse output and ensure extracted JS matches expectations.
|
|
41
|
-
- Update README usage to note supported ESLint 9.x and Eta major once validated.
|