Skip to content

Commit a5c8c77

Browse files
committed
Add eslint, husky, oxlint, and tap
1 parent 006ccb2 commit a5c8c77

18 files changed

+14627
-2886
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Thumbs.db
44
/.env
55
/.nvm
6+
/.tap
67
/.vscode
78
/npm-debug.log
89
/yarn.lock

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm test

.oxlintrc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["import", "promise", "typescript", "unicorn"],
4+
"categories": {
5+
"correctness": "warn",
6+
"perf": "warn",
7+
"suspicious": "warn"
8+
},
9+
"settings": {},
10+
"rules": {
11+
"@typescript-eslint/no-misused-new": ["deny"],
12+
"@typescript-eslint/no-this-alias": ["deny"],
13+
"unicorn/no-empty-file": "allow",
14+
"unicorn/no-new-array": "allow",
15+
"no-control-regex": "allow",
16+
"no-extend-native": "allow",
17+
"no-new": "allow",
18+
"no-self-assign": "allow",
19+
"no-unused-vars": "allow"
20+
}
21+
}

.prettierrc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"arrowParens": "avoid",
3-
"semi": false,
4-
"singleQuote": true,
5-
"trailingComma": "none",
6-
"proseWrap": "always"
2+
"arrowParens": "avoid",
3+
"semi": false,
4+
"singleQuote": true,
5+
"trailingComma": "none",
6+
"proseWrap": "always"
77
}

.taprc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# vim: set filetype=yaml :
2+
allow-incomplete-coverage: true
3+
color: true
4+
coverage-report:
5+
- none
6+
disable-coverage: true
7+
include:
8+
- test/**/*.test.js
9+
passes: false
10+
reporter: base

.travis.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
language: node_js
22
node_js:
3-
- lts/*
4-
- 17
5-
- 16
6-
- 15
7-
- 14
8-
- 13
9-
- 12
10-
- 11
11-
- 10
3+
- lts/*
4+
- 17
5+
- 16
6+
- 15
7+
- 14
8+
- 13
9+
- 12
10+
- 11
11+
- 10

eslint.config.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
'use strict'
2+
3+
const path = require('node:path')
4+
5+
const { includeIgnoreFile } = require('@eslint/compat')
6+
const js = require('@eslint/js')
7+
const importXPlugin = require('eslint-plugin-import-x')
8+
const nodePlugin = require('eslint-plugin-n')
9+
const sortDestructureKeysPlugin = require('eslint-plugin-sort-destructure-keys')
10+
const unicornPlugin = require('eslint-plugin-unicorn')
11+
12+
const constants = require('@socketsecurity/registry/lib/constants')
13+
const { GIT_IGNORE, PRETTIER_IGNORE } = constants
14+
15+
const rootPath = __dirname
16+
17+
const gitignorePath = path.resolve(rootPath, GIT_IGNORE)
18+
const prettierignorePath = path.resolve(rootPath, PRETTIER_IGNORE)
19+
20+
module.exports = [
21+
includeIgnoreFile(gitignorePath),
22+
includeIgnoreFile(prettierignorePath),
23+
{
24+
files: ['**/*.{c,}js'],
25+
...importXPlugin.flatConfigs.recommended,
26+
languageOptions: {
27+
...importXPlugin.flatConfigs.recommended.languageOptions,
28+
ecmaVersion: 'latest',
29+
sourceType: 'script'
30+
},
31+
rules: {
32+
...importXPlugin.flatConfigs.recommended.rules,
33+
'import-x/no-named-as-default-member': 'off',
34+
'import-x/no-unresolved': ['error', { commonjs: true }],
35+
'import-x/order': [
36+
'warn',
37+
{
38+
groups: [
39+
'builtin',
40+
'external',
41+
'internal',
42+
['parent', 'sibling', 'index'],
43+
'type'
44+
],
45+
pathGroups: [
46+
{
47+
pattern: '@socket{registry,security}/**',
48+
group: 'internal'
49+
}
50+
],
51+
pathGroupsExcludedImportTypes: ['type'],
52+
'newlines-between': 'always',
53+
alphabetize: {
54+
order: 'asc'
55+
}
56+
}
57+
]
58+
}
59+
},
60+
{
61+
files: ['scripts/**/*.js', 'test/**/*.cjs'],
62+
...nodePlugin.configs['flat/recommended-script']
63+
},
64+
{
65+
files: ['scripts/**/*.js', 'test/**/*.cjs'],
66+
plugins: {
67+
'sort-destructure-keys': sortDestructureKeysPlugin,
68+
unicorn: unicornPlugin
69+
},
70+
rules: {
71+
...js.configs.recommended.rules,
72+
'n/exports-style': ['error', 'module.exports'],
73+
// The n/no-unpublished-bin rule does does not support non-trivial glob
74+
// patterns used in package.json "files" fields. In those cases we simplify
75+
// the glob patterns used.
76+
'n/no-unpublished-bin': ['error'],
77+
'n/no-unsupported-features/es-builtins': ['error'],
78+
'n/no-unsupported-features/es-syntax': ['error'],
79+
'n/no-unsupported-features/node-builtins': [
80+
'error',
81+
{
82+
ignores: ['test', 'test.describe'],
83+
// Lazily access constants.maintainedNodeVersions.
84+
version: constants.maintainedNodeVersions.previous
85+
}
86+
],
87+
'n/prefer-node-protocol': ['error'],
88+
'no-await-in-loop': ['error'],
89+
'no-control-regex': ['error'],
90+
'no-empty': ['error', { allowEmptyCatch: true }],
91+
'no-new': ['error'],
92+
'no-proto': ['error'],
93+
'no-unused-vars': [
94+
'error',
95+
{ argsIgnorePattern: '^_|^this$', ignoreRestSiblings: true }
96+
],
97+
'no-warning-comments': ['warn', { terms: ['fixme'] }],
98+
'sort-destructure-keys/sort-destructure-keys': ['error'],
99+
'sort-imports': ['error', { ignoreDeclarationSort: true }],
100+
'unicorn/consistent-function-scoping': ['error']
101+
}
102+
}
103+
]

index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ SOFTWARE.
2222
'use strict'
2323

2424
const {
25-
PackageURL,
26-
PurlComponent,
27-
PurlQualifierNames,
28-
PurlType
25+
PackageURL,
26+
PurlComponent,
27+
PurlQualifierNames,
28+
PurlType
2929
} = require('./src/package-url')
3030

3131
module.exports = {
32-
PackageURL,
33-
PurlComponent,
34-
PurlQualifierNames,
35-
PurlType
32+
PackageURL,
33+
PurlComponent,
34+
PurlQualifierNames,
35+
PurlType
3636
}

0 commit comments

Comments
 (0)