Skip to content

Commit d4df4d7

Browse files
authored
Eslint v9 (#548)
2 parents 99fa829 + 1c9ce86 commit d4df4d7

26 files changed

Lines changed: 5071 additions & 1804 deletions

.eslintrc

Lines changed: 0 additions & 20 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import globals from 'globals'
2+
import js from '@eslint/js'
3+
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
4+
import stylistic from '@stylistic/eslint-plugin'
5+
import noOnlyTests from 'eslint-plugin-no-only-tests'
6+
7+
export default [
8+
{
9+
files: ['**/*.js'],
10+
languageOptions: {
11+
globals: {
12+
...globals.browser
13+
},
14+
sourceType: 'script'
15+
}
16+
},
17+
{
18+
files: ['test/**/*.js'],
19+
languageOptions: {
20+
globals: {
21+
...globals.browser,
22+
...globals.mocha
23+
},
24+
sourceType: 'script'
25+
}
26+
},
27+
{
28+
ignores: [
29+
...resolveIgnoresFromGitignore()
30+
]
31+
},
32+
js.configs.recommended,
33+
...neostandard(),
34+
{
35+
plugins: {
36+
'@stylistic': stylistic,
37+
'no-only-tests': noOnlyTests
38+
},
39+
rules: {
40+
// built-in
41+
'object-shorthand': ['error'],
42+
'no-console': ['error', { allow: ['debug', 'info', 'warn', 'error'] }],
43+
44+
// plugin:stylistic
45+
'@stylistic/indent': ['warn', 4], // https://eslint.style/rules/indent#options
46+
'@stylistic/spaced-comment': ['error', 'always'], // https://eslint.style/rules/spaced-comment
47+
'@stylistic/no-multi-spaces': 'error', // https://eslint.style/rules/no-multi-spaces#no-multi-spaces
48+
'@stylistic/comma-dangle': ['error', 'never'], // https://eslint.style/rules/comma-dangle#comma-dangle
49+
50+
// plugin:no-only-tests
51+
'no-only-tests/no-only-tests': 'error'
52+
}
53+
}
54+
]

frontend/routes.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,14 @@ function isAuthorized (req) {
302302
*/
303303
function encodingForContentType (contentType) {
304304
switch (contentType) {
305-
case 'text/plain':
306-
case 'text/html':
307-
case 'text/css':
308-
case 'application/json':
309-
case 'application/x-yaml':
310-
return 'utf8'
311-
default:
312-
return 'binary'
305+
case 'text/plain':
306+
case 'text/html':
307+
case 'text/css':
308+
case 'application/json':
309+
case 'application/x-yaml':
310+
return 'utf8'
311+
default:
312+
return 'binary'
313313
}
314314
}
315315

@@ -321,31 +321,31 @@ function encodingForContentType (contentType) {
321321
*/
322322
function contentTypeForExtension (ext) {
323323
switch (ext) {
324-
case '.txt':
325-
case '.log':
326-
return 'text/plain'
327-
case '.json':
328-
return 'application/json'
329-
case '.yaml':
330-
case '.yml':
331-
return 'application/x-yaml'
332-
case '.pdf':
333-
return 'application/pdf'
334-
case '.css':
335-
return 'text/css'
336-
case '.html':
337-
return 'text/html'
338-
case '.png':
339-
return 'image/png'
340-
case '.jpg':
341-
case '.jpeg':
342-
return 'image/jpeg'
343-
case '.gif':
344-
return 'image/gif'
345-
case '.svg':
346-
return 'image/svg+xml'
347-
case '.ico':
348-
return 'image/x-icon'
324+
case '.txt':
325+
case '.log':
326+
return 'text/plain'
327+
case '.json':
328+
return 'application/json'
329+
case '.yaml':
330+
case '.yml':
331+
return 'application/x-yaml'
332+
case '.pdf':
333+
return 'application/pdf'
334+
case '.css':
335+
return 'text/css'
336+
case '.html':
337+
return 'text/html'
338+
case '.png':
339+
return 'image/png'
340+
case '.jpg':
341+
case '.jpeg':
342+
return 'image/jpeg'
343+
case '.gif':
344+
return 'image/gif'
345+
case '.svg':
346+
return 'image/svg+xml'
347+
case '.ico':
348+
return 'image/x-icon'
349349
}
350350
return null
351351
}

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22
const semver = require('semver')
33
if (semver.lt(process.version, '14.0.0')) {
4+
// eslint-disable-next-line no-console
45
console.log('FlowFuse Device Agent requires at least NodeJS v14.x')
56
process.exit(1)
67
}
@@ -25,6 +26,7 @@ const chalk = require('yoctocolors-cjs') // switch to the lighter yoctocolors-cj
2526
function main (testOptions) {
2627
const pkg = require('./package.json')
2728
if (pkg.name === '@flowforge/flowforge-device-agent') {
29+
// eslint-disable-next-line no-console
2830
console.log(`
2931
**************************************************************************
3032
* The FlowFuse Device Agent is moving to '@flowfuse/device-agent' on npm *
@@ -41,16 +43,16 @@ function main (testOptions) {
4143
options = commandLineArgs(require('./lib/cli/args'), { camelCase: true })
4244
options = options._all
4345
} catch (err) {
44-
console.log(err.toString())
45-
console.log('Run with -h for help')
46+
console.error(err)
47+
console.error('Run with -h for help')
4648
quit()
4749
}
4850
if (options.version) {
49-
console.log(pkg.version)
51+
console.error(pkg.version)
5052
quit()
5153
}
5254
if (options.help) {
53-
console.log(require('./lib/cli/usage').usage())
55+
console.error(require('./lib/cli/usage').usage())
5456
quit()
5557
}
5658

@@ -318,7 +320,7 @@ Please ensure the parent directory is writable, or set a different path with -d`
318320
}
319321

320322
function quit (msg, errCode = 0) {
321-
if (msg) { console.log(msg) }
323+
if (msg) { console.error(msg) }
322324
if (TESTING) {
323325
// don't exit if we are testing. Instead, call the onExit callback stub
324326
if (testOptions?.onExit) {

installer/go/.releaserc.js

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,65 @@
11
module.exports = {
2-
tagFormat: 'installer-v${version}',
3-
branches: ['main'],
4-
plugins: [
5-
['@semantic-release/commit-analyzer', {
6-
preset: 'angular',
7-
releaseRules: [
8-
{ scope: '!installer', release: false },
9-
{ scope: 'installer', type: 'feat', release: 'minor' },
10-
{ scope: 'installer', type: 'fix', release: 'patch' },
11-
{ scope: 'installer', type: 'perf', release: 'patch' },
12-
{ scope: 'installer', type: 'refactor', release: 'patch' },
13-
{ scope: 'installer', type: 'chore', release: 'patch' },
14-
{ scope: 'installer', type: 'docs', release: 'patch' },
15-
{ scope: 'installer', type: 'style', release: 'patch' },
16-
{ scope: 'installer', type: 'test', release: 'patch' },
17-
{ scope: 'installer', breaking: true, release: 'major' }
18-
],
19-
parserOpts: {
20-
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES']
21-
}
22-
}],
23-
['@semantic-release/release-notes-generator', {
24-
preset: 'angular',
25-
parserOpts: {
26-
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES']
27-
},
28-
writerOpts: {
29-
transform: (commit) => {
30-
// Only include commits with 'installer' scope
31-
if (commit.scope !== 'installer') {
32-
return false;
33-
}
34-
// Clear the scope to prevent it from being displayed
35-
commit.scope = null;
36-
return commit;
37-
},
38-
}
39-
}],
40-
['@semantic-release/github', {
41-
releaseNameTemplate: 'Installer v${nextRelease.version}',
42-
successComment: false,
43-
assets: [
44-
{
45-
path: 'release-artifacts/flowfuse-device-installer-linux-amd64'
46-
},
47-
{
48-
path: 'release-artifacts/flowfuse-device-installer-linux-arm64'
49-
},
50-
{
51-
path: 'release-artifacts/flowfuse-device-installer-linux-arm'
52-
},
53-
{
54-
path: 'release-artifacts/flowfuse-device-installer-windows-amd64.exe'
55-
},
56-
{
57-
path: 'release-artifacts/flowfuse-device-installer-darwin-amd64'
58-
},
59-
{
60-
path: 'release-artifacts/flowfuse-device-installer-darwin-arm64'
61-
}
62-
]
63-
}]
64-
]
65-
};
2+
tagFormat: 'installer-v${version}', // eslint-disable-line no-template-curly-in-string
3+
branches: ['main'],
4+
plugins: [
5+
['@semantic-release/commit-analyzer', {
6+
preset: 'angular',
7+
releaseRules: [
8+
{ scope: '!installer', release: false },
9+
{ scope: 'installer', type: 'feat', release: 'minor' },
10+
{ scope: 'installer', type: 'fix', release: 'patch' },
11+
{ scope: 'installer', type: 'perf', release: 'patch' },
12+
{ scope: 'installer', type: 'refactor', release: 'patch' },
13+
{ scope: 'installer', type: 'chore', release: 'patch' },
14+
{ scope: 'installer', type: 'docs', release: 'patch' },
15+
{ scope: 'installer', type: 'style', release: 'patch' },
16+
{ scope: 'installer', type: 'test', release: 'patch' },
17+
{ scope: 'installer', breaking: true, release: 'major' }
18+
],
19+
parserOpts: {
20+
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES']
21+
}
22+
}],
23+
['@semantic-release/release-notes-generator', {
24+
preset: 'angular',
25+
parserOpts: {
26+
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES']
27+
},
28+
writerOpts: {
29+
transform: (commit) => {
30+
// Only include commits with 'installer' scope
31+
if (commit.scope !== 'installer') {
32+
return false
33+
}
34+
// Clear the scope to prevent it from being displayed
35+
commit.scope = null
36+
return commit
37+
}
38+
}
39+
}],
40+
['@semantic-release/github', {
41+
releaseNameTemplate: 'Installer v${nextRelease.version}', // eslint-disable-line no-template-curly-in-string
42+
successComment: false,
43+
assets: [
44+
{
45+
path: 'release-artifacts/flowfuse-device-installer-linux-amd64'
46+
},
47+
{
48+
path: 'release-artifacts/flowfuse-device-installer-linux-arm64'
49+
},
50+
{
51+
path: 'release-artifacts/flowfuse-device-installer-linux-arm'
52+
},
53+
{
54+
path: 'release-artifacts/flowfuse-device-installer-windows-amd64.exe'
55+
},
56+
{
57+
path: 'release-artifacts/flowfuse-device-installer-darwin-amd64'
58+
},
59+
{
60+
path: 'release-artifacts/flowfuse-device-installer-darwin-arm64'
61+
}
62+
]
63+
}]
64+
]
65+
}

0 commit comments

Comments
 (0)