generator-sublimelinter 0.2.2 → 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018-2026 Jan T. Sott
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,39 +1,45 @@
1
1
  # generator-sublimelinter
2
2
 
3
- [![npm](https://flat.badgen.net/npm/license/generator-sublimelinter)](https://www.npmjs.org/package/generator-sublimelinter)
4
- [![npm](https://flat.badgen.net/npm/v/generator-sublimelinter)](https://www.npmjs.org/package/generator-sublimelinter)
5
- [![CircleCI](https://flat.badgen.net/circleci/github/idleberg/generator-sublimelinter)](https://circleci.com/gh/idleberg/generator-sublimelinter)
6
- [![David](https://flat.badgen.net/david/dep/idleberg/generator-sublimelinter)](https://david-dm.org/idleberg/generator-sublimelinter)
3
+ > A [Yeoman](http://yeoman.io/authoring/user-interactions.html) generator for SublimeLinter plugins.
7
4
 
8
- ## Description
5
+ [![License](https://img.shields.io/github/license/idleberg/generator-sublimelinter?color=blue&style=for-the-badge)](https://github.com/idleberg/generator-sublimelinter/blob/main/LICENSE)
6
+ [![Version](https://img.shields.io/npm/v/generator-sublimelinter?style=for-the-badge)](https://www.npmjs.org/package/generator-sublimelinter)
7
+ [![Build](https://img.shields.io/github/actions/workflow/status/idleberg/generator-sublimelinter/default.yml?style=for-the-badge)](https://github.com/idleberg/generator-sublimelinter/actions)
9
8
 
10
- A [Yeoman](http://yeoman.io/authoring/user-interactions.html) generator for SublimeLinter plugins.
9
+ ## Description
11
10
 
12
11
  **Features**
13
12
 
14
13
  - adds any [SPDX](https://spdx.org/licenses/) license
15
- - adds [CircleCI](https://circleci.com/) configuration
16
- - adds [Travis CI](https://travis-ci.org/) configuration
14
+ - adds CI/CD configuration
17
15
  - adds [EditorConfig](https://editorconfig.org/) configuration
18
16
 
17
+ ## Prerequisites
18
+
19
+ You need [Node.js](https://nodejs.org) installed and available in your `PATH` [environment variable](http://superuser.com/a/284351/195953). Use your preferred Node package manager to install the Yeoman CLI tool.
20
+
21
+ ```sh
22
+ $ npm install -g yo
23
+ ```
24
+
19
25
  ## Installation
20
26
 
21
- Use your preferred [Node](https://nodejs.org/) package manager to install the CLI tool
27
+ Use your preferred package manager to install this generator
22
28
 
23
29
  ```sh
24
- npm i generator-sublimelinter -g
30
+ $ npm i generator-sublime -g
25
31
  ```
26
32
 
27
33
  ## Usage
28
34
 
29
- Run the generator and follow its instructions. Use `--help`to list available flags.
35
+ Run the generator and follow its instructions. Use `--help` for available flags.
30
36
 
31
37
  ```sh
32
- yo sublimelinter
38
+ $ yo sublime
33
39
  ```
34
40
 
35
41
  *“That's all Folks!”*
36
42
 
37
43
  ## License
38
44
 
39
- This work is licensed under the [MIT License](https://opensource.org/licenses/MIT)
45
+ This work is licensed under the [MIT License](LICENSE).
@@ -1,358 +1,276 @@
1
- const Generator = require('yeoman-generator');
2
- const pkg = require('../../package.json');
1
+ import { mkdir } from 'node:fs/promises';
2
+ import { resolve } from 'node:path';
3
+ import slugify from '@sindresorhus/slugify';
4
+ import { pascalCase } from 'pascal-case';
5
+ import semver from 'semver';
6
+ import spdxLicenseList from 'spdx-license-list/full.js';
7
+ import terminalLink from 'terminal-link';
8
+ import Generator from 'yeoman-generator';
9
+ import { getDefaultSelector, licenseChoices, validateName } from '../lib/helpers.js';
3
10
 
4
- const mkdirp = require('mkdirp');
5
- const pascalCase = require('pascal-case');
6
- const semver = require('semver');
7
- const slugify = require('@sindresorhus/slugify');
8
- const spdxLicenseList = require('spdx-license-list/full');
9
- const terminalLink = require('terminal-link');
10
- const updateNotifier = require('update-notifier');
11
- const { join } = require('path');
11
+ export default class extends Generator {
12
+ constructor(args, opts) {
13
+ super(args, opts);
12
14
 
13
- // Is there a newer version of this generator?
14
- updateNotifier({ pkg: pkg }).notify();
15
+ this.option('loose-version', { description: `Doesn't enforce semantic versioning`, default: false });
16
+ this.option('debug', { description: 'Prints debug messages', default: false });
15
17
 
16
- // Create array of license choices
17
- const spdxCodes = Object.getOwnPropertyNames(spdxLicenseList).sort();
18
- const licenseChoices = spdxCodes.map(obj => {
19
- const licenses = {};
20
- licenses['name'] = terminalLink(obj, `https://spdx.org/licenses/${obj}.html`, {
21
- fallback() {
22
- return obj;
23
- }
24
- });
25
- licenses['value'] = obj;
18
+ this.looseVersion = this.options.looseVersion;
19
+ this.debug = this.options.debug;
26
20
 
27
- return licenses;
28
- });
21
+ console.log(/* let it breathe */);
22
+ }
29
23
 
30
- const validateName = str => {
31
- if (str.startsWith('SublimeLinter-')) {
32
- return false;
33
- } else if (str.startsWith('SublimeLinter-contrib-')) {
34
- return false;
35
- } else if (str.startsWith('sublime-linter-')) {
36
- return false;
37
- } else if (str.startsWith('sublime-linter-contrib-')) {
38
- return false;
39
- }
24
+ async inquirer() {
25
+ return this.prompt([
26
+ {
27
+ name: 'name',
28
+ message: `What's name of the linter executable?`,
29
+ default: slugify(this.appname),
30
+ store: true,
31
+ validate: (str) =>
32
+ validateName(str) === false ? `Specify the linter's name without SublimeLinter prefixes` : true,
33
+ },
34
+ {
35
+ name: 'version',
36
+ message: `What's the plugin's initial version?`,
37
+ default: '0.0.0',
38
+ store: true,
39
+ validate: (version) =>
40
+ this.looseVersion === true || semver.valid(version) !== null
41
+ ? true
42
+ : `Not a valid ${terminalLink('semantic version', 'https://semver.org', {
43
+ fallback() {
44
+ return 'semantic version';
45
+ },
46
+ })}`,
47
+ },
48
+ {
49
+ name: 'interface',
50
+ message: 'Specify the linter interface',
51
+ type: 'list',
52
+ default: '(default)',
53
+ store: true,
54
+ choices: [
55
+ {
56
+ name: '(default)',
57
+ value: 'Linter',
58
+ },
59
+ {
60
+ name: 'Composer',
61
+ value: 'ComposerLinter',
62
+ },
63
+ {
64
+ name: 'Node',
65
+ value: 'NodeLinter',
66
+ },
67
+ {
68
+ name: terminalLink('Python', 'http://www.sublimelinter.com/en/stable/python_linter.html', {
69
+ fallback() {
70
+ return 'Python';
71
+ },
72
+ }),
73
+ value: 'PythonLinter',
74
+ },
75
+ {
76
+ name: terminalLink('Ruby', 'http://www.sublimelinter.com/en/stable/ruby_linter.html', {
77
+ fallback() {
78
+ return 'Ruby';
79
+ },
80
+ }),
81
+ value: 'RubyLinter',
82
+ },
83
+ ],
84
+ },
85
+ {
86
+ name: 'selector',
87
+ message: `Specify the ${terminalLink(
88
+ 'selector',
89
+ 'http://www.sublimelinter.com/en/stable/linter_settings.html#selector',
90
+ {
91
+ fallback() {
92
+ return 'selector';
93
+ },
94
+ },
95
+ )}`,
96
+ default: (answers) => getDefaultSelector(answers.interface),
97
+ store: true,
98
+ validate: (x) => (x.length > 0 ? true : 'You have to provide a valid selector'),
99
+ },
100
+ {
101
+ name: 'errorStream',
102
+ message: `Specify the default ${terminalLink(
103
+ 'error stream',
104
+ 'http://www.sublimelinter.com/en/stable/linter_attributes.html#error-stream',
105
+ {
106
+ fallback() {
107
+ return 'error stream';
108
+ },
109
+ },
110
+ )}`,
111
+ type: 'list',
112
+ default: 'STREAM_BOTH',
113
+ choices: [
114
+ {
115
+ name: 'both',
116
+ value: 'STREAM_BOTH',
117
+ },
118
+ {
119
+ name: 'stderr',
120
+ value: 'STREAM_STDERR',
121
+ },
122
+ {
123
+ name: 'stdout',
124
+ value: 'STREAM_STDOUT',
125
+ },
126
+ ],
127
+ store: true,
128
+ },
129
+ {
130
+ name: 'multiline',
131
+ message: `RegEx pattern is ${terminalLink(
132
+ 'multiline',
133
+ 'http://www.sublimelinter.com/en/stable/linter_attributes.html#multiline',
134
+ {
135
+ fallback() {
136
+ return 'multiline';
137
+ },
138
+ },
139
+ )}`,
140
+ type: 'confirm',
141
+ default: false,
142
+ store: true,
143
+ },
144
+ {
145
+ name: 'author',
146
+ message: `What's your GitHub username?`,
147
+ store: true,
148
+ validate: (x) => (x.length > 0 ? true : 'You have to provide a username'),
149
+ },
150
+ {
151
+ name: 'spdxLicense',
152
+ message: 'Choose a license',
153
+ type: 'list',
154
+ default: 'MIT',
155
+ choices: licenseChoices,
156
+ store: true,
157
+ },
158
+ {
159
+ type: 'checkbox',
160
+ name: 'tests',
161
+ message: 'Add tests',
162
+ store: true,
163
+ choices: [
164
+ {
165
+ name: terminalLink('Circle CI', 'https://circleci.com/', {
166
+ fallback() {
167
+ return 'Circle CI';
168
+ },
169
+ }),
170
+ value: 'circleCI',
171
+ checked: false,
172
+ },
173
+ {
174
+ name: terminalLink('GitHub Workflow', 'https://docs.github.com/en/actions/using-workflows', {
175
+ fallback() {
176
+ return 'GitHub Workflow';
177
+ },
178
+ }),
179
+ value: 'githubWorkflow',
180
+ checked: false,
181
+ },
182
+ ],
183
+ },
184
+ {
185
+ name: 'flakeArgs',
186
+ message: `Specify ${terminalLink('flake8', 'http://flake8.pycqa.org/', {
187
+ fallback() {
188
+ return 'flake8';
189
+ },
190
+ })} arguments`,
191
+ default: '-ignore=D211',
192
+ store: true,
193
+ when: (answers) => answers.tests.length > 0,
194
+ },
195
+ {
196
+ name: 'pepArgs',
197
+ message: `Specify ${terminalLink('pep257', 'https://pep257.readthedocs.io/', {
198
+ fallback() {
199
+ return 'pep257';
200
+ },
201
+ })} arguments`,
202
+ default: '--ignore=D211',
203
+ store: true,
204
+ when: (answers) => answers.tests.length > 0,
205
+ },
206
+ {
207
+ name: 'initGit',
208
+ message: 'Initialize Git repository?',
209
+ type: 'confirm',
210
+ default: !this.fs.exists(resolve(process.cwd(), '.git', 'config')),
211
+ },
212
+ ]).then(async (props) => {
213
+ if (this.options.debug) {
214
+ console.log(props);
215
+ }
40
216
 
41
- return true;
42
- };
217
+ props.slug = slugify(props.name);
218
+ props.repositoryName = `SublimeLinter-contrib-${props.slug}`;
219
+ props.className = pascalCase(props.name);
220
+ props.multiline = props.multiline === true ? 'True' : 'False';
43
221
 
44
- const defaultSelector = linterInterface => {
45
- if (linterInterface === 'ComposerLinter') {
46
- return 'source.php';
47
- } else if (linterInterface === 'NodeLinter') {
48
- return 'source.js';
49
- } else if (linterInterface === 'PythonLinter') {
50
- return 'source.py';
51
- } else if (linterInterface === 'RubyLinter') {
52
- return 'source.rb';
53
- }
222
+ if (typeof props.spdxLicense !== 'undefined') {
223
+ props.licenseName = spdxLicenseList[props.spdxLicense].name;
224
+ props.licenseText = spdxLicenseList[props.spdxLicense].licenseText.replace(/\n{3,}/g, '\n\n');
225
+ }
54
226
 
55
- return 'source.example';
56
- }
57
-
58
- module.exports = class extends Generator {
59
- constructor(args, opts) {
60
- super(args, opts);
61
-
62
- this.option('loose-version', { desc: `Doesn't enforce semantic versioning`, default: false });
227
+ if (typeof props.spdxLicense !== 'undefined') {
228
+ this.fs.copyTpl(this.templatePath('LICENSE.ejs'), this.destinationPath('LICENSE'), {
229
+ licenseText: props.licenseText,
230
+ });
231
+ }
63
232
 
64
- this.looseVersion = (this.options.looseVersion ? true : false);
65
- }
233
+ if (props.tests.includes('circleCI')) {
234
+ await mkdir('.circleci', {
235
+ recursive: true,
236
+ });
66
237
 
67
- inquirer() {
68
- return this.prompt([
69
- {
70
- name: 'name',
71
- message: `What's name of the linter executable?`,
72
- default: slugify(this.appname),
73
- store: true,
74
- validate: str => (validateName(str) === false) ? `Specify the linter's name without SublimeLinter prefixes` : true
75
- },
76
- {
77
- name: 'version',
78
- message: `What's the plugin's initial version?`,
79
- default: '0.0.0',
80
- store: true,
81
- validate: version => (this.looseVersion === true || semver.valid(version) !== null) ? true : `Not a valid ${terminalLink(
82
- 'semantic version',
83
- 'https://semver.org',
84
- {
85
- fallback() {
86
- return 'semantic version';
87
- }
88
- }
89
- )}`
90
- },
91
- {
92
- name: 'interface',
93
- message: 'Specify the linter interface',
94
- type: 'list',
95
- default: '(default)',
96
- store: true,
97
- choices: [
98
- {
99
- name: '(default)',
100
- value: 'Linter'
101
- },
102
- {
103
- name: 'Composer',
104
- value: 'ComposerLinter'
105
- },
106
- {
107
- name: 'Node',
108
- value: 'NodeLinter'
109
- },
110
- {
111
- name: terminalLink('Python', 'http://www.sublimelinter.com/en/stable/python_linter.html',
112
- {
113
- fallback() {
114
- return 'Python';
115
- }
116
- }
117
- ),
118
- value: 'PythonLinter'
119
- },
120
- {
121
- name: terminalLink(
122
- 'Ruby',
123
- 'http://www.sublimelinter.com/en/stable/ruby_linter.html',
124
- {
125
- fallback() {
126
- return 'Ruby';
127
- }
128
- }
129
- ),
130
- value: 'RubyLinter'
131
- }
132
- ]
133
- },
134
- {
135
- name: 'selector',
136
- message: `Specify the ${terminalLink('selector', 'http://www.sublimelinter.com/en/stable/linter_settings.html#selector',
137
- {
138
- fallback() {
139
- return 'selector';
140
- }
141
- }
142
- )}`,
143
- default: answers => defaultSelector(answers.interface),
144
- store: true,
145
- validate: x => x.length > 0 ? true : 'You have to provide a valid selector'
146
- },
147
- {
148
- name: 'errorStream',
149
- message: `Specify the default ${terminalLink('error stream', 'http://www.sublimelinter.com/en/stable/linter_attributes.html#error-stream',
150
- {
151
- fallback() {
152
- return 'error stream';
153
- }
154
- }
155
- )}`,
156
- type: 'list',
157
- default: 'STREAM_BOTH',
158
- choices: [
159
- {
160
- name: 'both',
161
- value: 'STREAM_BOTH'
162
- },
163
- {
164
- name: 'stderr',
165
- value: 'STREAM_STDERR'
166
- },
167
- {
168
- name: 'stdout',
169
- value: 'STREAM_STDOUT'
170
- }
171
- ],
172
- store: true
173
- },
174
- {
175
- name: 'multiline',
176
- message: `RegEx pattern is ${terminalLink('multiline', 'http://www.sublimelinter.com/en/stable/linter_attributes.html#multiline',
177
- {
178
- fallback() {
179
- return 'multiline';
180
- }
181
- }
182
- )}`,
183
- type: 'confirm',
184
- default: false,
185
- store: true
186
- },
187
- {
188
- name: 'author',
189
- message: `What's your GitHub username?`,
190
- default: async () => await this.user.github.username(),
191
- store: true,
192
- validate: x => x.length > 0 ? true : 'You have to provide a username'
193
- },
194
- {
195
- name: 'spdxLicense',
196
- message: 'Choose a license',
197
- type: 'list',
198
- default: 'MIT',
199
- choices: licenseChoices,
200
- store: true,
201
- },
202
- {
203
- type: 'checkbox',
204
- name: 'tests',
205
- message: 'Add tests',
206
- store: true,
207
- choices: [
208
- {
209
- name: terminalLink(
210
- 'Circle CI',
211
- 'https://circleci.com/',
212
- {
213
- fallback() {
214
- return 'Circle CI';
215
- }
216
- }
217
- ),
218
- value: 'circleCI',
219
- checked: false
220
- },
221
- {
222
- name: terminalLink(
223
- 'Travis CI',
224
- 'https://travis-ci.org/',
225
- {
226
- fallback() {
227
- return 'Travis CI';
228
- }
229
- }
230
- ),
231
- value: 'travisCI',
232
- checked: false
233
- }
234
- ]
235
- },
236
- {
237
- name: 'flakeArgs',
238
- message: `Specify ${terminalLink(
239
- 'flake8',
240
- 'http://flake8.pycqa.org/',
241
- {
242
- fallback() {
243
- return 'flake8'
244
- }
245
- }
246
- )} arguments`,
247
- 'default': '-ignore=D211',
248
- store: true,
249
- when: answers => (answers.tests.length > 0) ? true : false
250
- },
251
- {
252
- name: 'pepArgs',
253
- message: `Specify ${terminalLink(
254
- 'pep257',
255
- 'https://pep257.readthedocs.io/',
256
- {
257
- fallback() {
258
- return 'pep257'
259
- }
260
- }
261
- )} arguments`,
262
- 'default': '--ignore=D211',
263
- store: true,
264
- when: answers => (answers.tests.length > 0) ? true : false
265
- },
266
- {
267
- name: 'initGit',
268
- message: 'Initialize Git repository?',
269
- type: 'confirm',
270
- default: this.fs.exists(join(process.cwd(), '.git', 'config')) ? false : true
271
- },
272
- {
273
- name: 'openInEditor',
274
- message: 'Open in default editor?',
275
- type: 'confirm',
276
- default: 'true',
277
- store: true,
278
- when: () => {
279
- return (process.env.EDITOR) ? true : false;
280
- }
281
- },
282
- ]).then(props => {
283
- props.slug = slugify(props.name);
284
- props.repositoryName = `SublimeLinter-contrib-${props.slug}`;
285
- props.className = pascalCase(props.name);
286
- props.multiline = (props.multiline === true) ? 'True' : 'False';
238
+ this.fs.copyTpl(this.templatePath('config-circleci.ejs'), this.destinationPath('.circleci/config.yml'), {
239
+ flakeArgs: props.flakeArgs.trim(),
240
+ pepArgs: props.pepArgs.trim(),
241
+ });
242
+ }
287
243
 
288
- if (typeof props.spdxLicense !== 'undefined') {
289
- props.licenseName = spdxLicenseList[props.spdxLicense].name;
290
- props.licenseText = spdxLicenseList[props.spdxLicense].licenseText.replace(/\n{3,}/g, '\n\n');
291
- }
244
+ if (props.tests.includes('githubWorkflow')) {
245
+ await mkdir('.github/workflows', {
246
+ recursive: true,
247
+ });
292
248
 
293
- if (typeof props.spdxLicense !== 'undefined') {
294
- this.fs.copyTpl(
295
- this.templatePath('LICENSE.ejs'),
296
- this.destinationPath('LICENSE'),
297
- {
298
- licenseText: props.licenseText
299
- }
300
- );
301
- }
249
+ this.fs.copyTpl(this.templatePath('config-github.ejs'), this.destinationPath('.github/workflows/config.yml'), {
250
+ flakeArgs: props.flakeArgs.trim(),
251
+ pepArgs: props.pepArgs.trim(),
252
+ });
253
+ }
302
254
 
303
- if (props.tests.includes('circleCI')) {
304
- mkdirp('.circleci');
305
- this.fs.copyTpl(
306
- this.templatePath('config.yml.ejs'),
307
- this.destinationPath('.circleci/config.yml'),
308
- {
309
- flakeArgs: ` ${props.flakeArgs.trim()}`,
310
- pepArgs: ` ${props.pepArgs.trim()}`
311
- }
312
- );
313
- }
255
+ this.fs.copy(this.templatePath('_editorconfig'), this.destinationPath('.editorconfig'));
314
256
 
315
- if (props.tests.includes('travisCI')) {
316
- this.fs.copyTpl(
317
- this.templatePath('_travis.yml.ejs'),
318
- this.destinationPath('.travis.yml'),
319
- {
320
- flakeArgs: ` ${props.flakeArgs.trim()}`,
321
- pepArgs: ` ${props.pepArgs.trim()}`
322
- }
323
- );
324
- }
257
+ this.fs.copyTpl(this.templatePath('linter.py.ejs'), this.destinationPath('linter.py'), {
258
+ props: props,
259
+ });
325
260
 
326
- this.fs.copy(
327
- this.templatePath('_editorconfig'),
328
- this.destinationPath('.editorconfig'),
329
- );
261
+ this.fs.copyTpl(this.templatePath('README.md.ejs'), this.destinationPath('README.md'), {
262
+ props: props,
263
+ });
330
264
 
331
- this.fs.copyTpl(
332
- this.templatePath('linter.py.ejs'),
333
- this.destinationPath('linter.py'),
334
- {
335
- props: props
336
- }
337
- );
265
+ // Initialize git repository
266
+ if (props.initGit) {
267
+ this.spawnSync('git', ['init']);
268
+ }
338
269
 
339
- this.fs.copyTpl(
340
- this.templatePath('README.md.ejs'),
341
- this.destinationPath('README.md'),
342
- {
343
- props: props
344
- }
345
- );
346
-
347
- // Initialize git repository
348
- if (props.initGit) {
349
- this.spawnCommandSync('git', ['init']);
350
- }
351
-
352
- // Open in Editor
353
- if (props.openInEditor === true) {
354
- this.spawnCommand(process.env.EDITOR, [ '.' ]);
355
- }
356
- });
357
- }
358
- };
270
+ // Open in Editor
271
+ if (props.openInEditor === true && typeof process.env.EDITOR === 'string') {
272
+ this.spawn(String(process.env.EDITOR), ['.']);
273
+ }
274
+ });
275
+ }
276
+ }
@@ -1,8 +1,7 @@
1
1
  # <%= props.repositoryName %>
2
2
 
3
3
  [![<%= props.licenseName %>](https://flat.badgen.net/badge/license/<%= props.spdxLicense %>/blue)](https://opensource.org/licenses/<%= props.spdxLicense %>)<% if (props.tests.includes('circleCI')) { %>
4
- [![CircleCI](https://flat.badgen.net/circleci/github/<%= props.author %>/<%= props.repositoryName %>)](https://circleci.com/gh/<%= props.author %>/<%= props.repositoryName %>)<% } %><% if (props.tests.includes('travisCI')) { %>
5
- [![Travis](https://flat.badgen.net/travis/<%= props.author %>/<%= props.repositoryName %>)](https://travis-ci.org/<%= props.author %>/<%= props.repositoryName %>)<% } %>
4
+ [![CircleCI](https://flat.badgen.net/circleci/github/<%= props.author %>/<%= props.repositoryName %>)](https://circleci.com/gh/<%= props.author %>/<%= props.repositoryName %>)<% } %>
6
5
 
7
6
  This linter plugin for [SublimeLinter](https://github.com/SublimeLinter/SublimeLinter) provides an interface to `<%= props.slug %>`
8
7
 
@@ -6,26 +6,31 @@ jobs:
6
6
  working_directory: ~/repo
7
7
  steps:
8
8
  - checkout
9
+
9
10
  - restore_cache:
10
11
  keys:
11
12
  - v1-dependencies-{{ checksum "linter.py" }}
12
13
  - v1-dependencies-
14
+
13
15
  - run:
14
16
  name: Install dependencies
15
17
  command: |
16
18
  python3 -m venv venv
17
19
  . venv/bin/activate
18
20
  pip install flake8 pep257
21
+
19
22
  - save_cache:
20
23
  paths:
21
24
  - ./venv
22
25
  key: v1-dependencies-{{ checksum "linter.py" }}
26
+
23
27
  - run:
24
28
  name: Run tests
25
29
  command: |
26
30
  . venv/bin/activate
27
- flake8 ./linter.py<%- flakeArgs %>
28
- pep257 ./linter.py<%- pepArgs %>
31
+ flake8 ./linter.py <%- flakeArgs %>
32
+ pep257 ./linter.py <%- pepArgs %>
33
+
29
34
  - store_artifacts:
30
35
  path: test-reports
31
36
  destination: test-reports
@@ -0,0 +1,59 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - '.github/**'
7
+ - 'linter.py'
8
+ - 'README.md'
9
+ pull_request:
10
+ paths:
11
+ - '.github/**'
12
+ - 'linter.py'
13
+ - 'README.md'
14
+ workflow_dispatch:
15
+
16
+ jobs:
17
+ default:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
22
+
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+ with:
26
+ fetch-depth: 1
27
+
28
+ - uses: actions/setup-python@v5
29
+ with:
30
+ cache: 'pip'
31
+ python-version: ${{ matrix.python-version }}
32
+
33
+ - uses: actions/cache@v5
34
+ name: Setup pnpm cache
35
+ with:
36
+ path: ./venv
37
+ key: ${{ runner.os }}-${{ hashFiles('linter.py') }}
38
+ restore-keys: |
39
+ ${{ runner.os }}-
40
+
41
+ - name: Install dependencies
42
+ run: |
43
+ if [ ! -d venv ]; then
44
+ python -m venv venv
45
+ . venv/bin/activate
46
+ pip install flake8 pep257
47
+ fi
48
+
49
+ - name: Run tests
50
+ run: |
51
+ . venv/bin/activate
52
+ flake8 ./linter.py <%- flakeArgs %>
53
+ pep257 ./linter.py <%- pepArgs %>
54
+
55
+ - name: Archive test reports
56
+ uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba #v4.3.2
57
+ with:
58
+ name: test-reports
59
+ path: test-reports
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # linter.py
3
- # Copyright (c) 2018 <%= props.author %>
3
+ # Copyright (c) <%- new Date().getYear() %>> <%= props.author %>
4
4
  # <%= props.licenseName %>
5
5
  #
6
6
  # https://github.com/<%= props.author %>/<%= props.repositoryName %>
@@ -0,0 +1,51 @@
1
+ // @ts-check
2
+ import spdxLicenseList from 'spdx-license-list/full.js';
3
+ import terminalLink from 'terminal-link';
4
+
5
+ const spdxCodes = Object.getOwnPropertyNames(spdxLicenseList).sort();
6
+
7
+ export const licenseChoices = spdxCodes.map((obj) => {
8
+ const licenses = {};
9
+ licenses.name = terminalLink(obj, `https://spdx.org/licenses/${obj}.html`, {
10
+ fallback: true,
11
+ });
12
+ licenses.value = obj;
13
+
14
+ return licenses;
15
+ });
16
+
17
+ /**
18
+ *
19
+ * @param {'ComposerLinter' | 'NodeLinter' | 'PythonLinter' | 'RubyLinter'} linterInterface
20
+ * @returns {'source.php' | 'source.js' | 'source.py' | 'source.rb' | 'source.example'}
21
+ */
22
+ export function getDefaultSelector(linterInterface) {
23
+ if (linterInterface === 'ComposerLinter') {
24
+ return 'source.php';
25
+ }
26
+ if (linterInterface === 'NodeLinter') {
27
+ return 'source.js';
28
+ }
29
+ if (linterInterface === 'PythonLinter') {
30
+ return 'source.py';
31
+ }
32
+ if (linterInterface === 'RubyLinter') {
33
+ return 'source.rb';
34
+ }
35
+
36
+ return 'source.example';
37
+ }
38
+
39
+ /**
40
+ *
41
+ * @param {string} name
42
+ * @returns {boolean}
43
+ */
44
+ export function validateName(name) {
45
+ if (name.startsWith('SublimeLinter-')) false;
46
+ if (name.startsWith('SublimeLinter-contrib-')) false;
47
+ if (name.startsWith('sublime-linter-')) false;
48
+ if (name.startsWith('sublime-linter-contrib-')) false;
49
+
50
+ return true;
51
+ }
package/package.json CHANGED
@@ -1,46 +1,61 @@
1
1
  {
2
2
  "name": "generator-sublimelinter",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "Yeoman generator for SublimeLinter plugins",
5
- "files": [
6
- "generators"
7
- ],
8
- "scripts": {
9
- "ejslint": "ejslint generators/**/*.ejs",
10
- "eslint": "eslint generators/**/*.js",
11
- "test": "npm run eslint && npm run ejslint"
12
- },
5
+ "author": "Jan T. Sott",
6
+ "license": "MIT",
13
7
  "keywords": [
14
8
  "yeoman-generator",
15
9
  "sublimelinter",
16
10
  "sublimelinter-plugin",
17
11
  "sublime text"
18
12
  ],
13
+ "type": "module",
14
+ "exports": "./generators/app",
15
+ "files": [
16
+ "generators",
17
+ "LICENSE",
18
+ "README.md"
19
+ ],
19
20
  "repository": {
20
21
  "type": "git",
21
22
  "url": "https://github.com/idleberg/generator-sublimelinter"
22
23
  },
23
- "author": "",
24
- "license": "MIT",
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
25
27
  "dependencies": {
26
- "@sindresorhus/slugify": "^0.9.1",
27
- "mkdirp": "^0.5.1",
28
- "pascal-case": "^2.0.1",
29
- "semver": "^6.3.0",
30
- "spdx-license-list": "^6.0.0",
31
- "terminal-link": "^1.3.0",
32
- "update-notifier": "^3.0.1",
33
- "yeoman-generator": "^4.0.1"
28
+ "@sindresorhus/slugify": "^3.0.0",
29
+ "pascal-case": "^4.0.0",
30
+ "semver": "^7.7.3",
31
+ "spdx-license-list": "^6.10.0",
32
+ "terminal-link": "^5.0.0",
33
+ "yeoman-generator": "^7.5.1"
34
34
  },
35
35
  "devDependencies": {
36
- "babel-eslint": "^10.0.2",
37
- "ejs-lint": "^0.3.0",
38
- "eslint": "^6.1.0",
39
- "husky": "^3.0.2"
36
+ "@commitlint/cli": "^20.3.0",
37
+ "@commitlint/config-conventional": "^20.3.0",
38
+ "@idleberg/configs": "^0.4.1",
39
+ "@lukeed/uuid": "^2.0.1",
40
+ "@types/yeoman-assert": "^3.1.4",
41
+ "@yeoman/adapter": "^3.0.0",
42
+ "@yeoman/types": "^1.8.0",
43
+ "concurrently": "^9.2.1",
44
+ "ejs-lint": "^2.0.1",
45
+ "mem-fs": "^4.1.2",
46
+ "np": "^10.2.0",
47
+ "vitest": "^4.0.16",
48
+ "yeoman-assert": "^3.1.1",
49
+ "yeoman-environment": "^5.1.1",
50
+ "yeoman-test": "^11.2.0"
40
51
  },
41
- "husky": {
42
- "hooks": {
43
- "pre-commit": "npm run test"
44
- }
52
+ "scripts": {
53
+ "lint:e18e": "#e18e-cli analyze",
54
+ "lint:ejs": "ejslint generators/**/*.ejs",
55
+ "lint:code": "biome check",
56
+ "lint": "concurrently --prefix '{name}' -c 'green,blue' 'npm:lint:*'",
57
+ "publish:npm": "np --no-yarn",
58
+ "test": "vitest run",
59
+ "test:watch": "vitest"
45
60
  }
46
- }
61
+ }
@@ -1,19 +0,0 @@
1
- sudo: false
2
- git:
3
- depth: 1
4
- branches:
5
- only:
6
- - master
7
- language: python
8
- python:
9
- - "3.4"
10
- - "3.5"
11
- - "3.6"
12
- - "3.7"
13
- install:
14
- - pip install flake8 pep257
15
- script:
16
- - flake8 ./linter.py<%- flakeArgs %>
17
- - pep257 ./linter.py<%- pepArgs %>
18
- notifications:
19
- email: false