Skip to content

Commit e2fc174

Browse files
committed
Some package maintenance
- Updated dependencies - Converted eslint to the new format - Test formatting - Updated README
1 parent 0e940c4 commit e2fc174

16 files changed

+2063
-5497
lines changed

.eslintrc.json

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

.github/workflows/publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
with:
1313
node-version: '20.x'
1414
registry-url: 'https://registry.npmjs.org'
15-
- run: npm i tslib -g
1615
- run: npm ci --no-optional
1716
- run: npm publish --scope=@topmarksdevelopment --access public
1817
env:

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,32 @@ A small package to provide an autocomplete list as a user is typing.
99
- [Change log](./CHANGELOG.md)
1010
- [License (MIT)](./LICENSE)
1111

12+
### Features
13+
14+
- Supports different sources; whether `string`, `object`, `array` or callback
15+
- Allows customization of the source type with strong types
16+
- Complete control over construction, with custom renderers
17+
- Option to automatically focus on the first element when the menu opens
18+
- Configurable delay between keystrokes and source calls
19+
- Supports a minimum term, before querying the source
20+
- Custom mapping of object properties to the generic type
21+
- Flexible positioning of the autocomplete box
22+
- Ability to append the menu to a specific element
23+
- Event callbacks for menu interactions and lifecycle events
24+
1225
## Usage
1326

1427
### Basic usage
1528

16-
To add autocomplete to an input with the class "`autocomplete`", use the sample code below - which will query the specified source URL and expect a JSON response.
17-
18-
Without specifying a type, autocomplete defaults to the generic type:
19-
`{ label: string; value: string }`
29+
> ℹ️ Without specifying a type, autocomplete defaults to the generic type:
30+
> `{ label: string; value: string }`
2031
2132
```TS
2233
// Using the default options (source is always required)
2334
new Autocomplete(
2435
'.autocomplete',
2536
{
37+
// Query this source & expect a JSON response
2638
source: './relative-folder/query.html'
2739
}
2840
)

eslint.config.mjs

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
'use strict';
2+
3+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
4+
import globals from 'globals';
5+
import tsParser from '@typescript-eslint/parser';
6+
import path from 'node:path';
7+
import { fileURLToPath } from 'node:url';
8+
import js from '@eslint/js';
9+
import { FlatCompat } from '@eslint/eslintrc';
10+
import stylistic from '@stylistic/eslint-plugin';
11+
12+
const __filename = fileURLToPath(import.meta.url);
13+
const __dirname = path.dirname(__filename);
14+
const compat = new FlatCompat({
15+
baseDirectory: __dirname,
16+
recommendedConfig: js.configs.recommended,
17+
allConfig: js.configs.all,
18+
});
19+
20+
export default [
21+
...compat.extends(
22+
'eslint:recommended',
23+
'plugin:@typescript-eslint/recommended',
24+
),
25+
{
26+
plugins: {
27+
'@stylistic': stylistic,
28+
'@typescript-eslint': typescriptEslint,
29+
},
30+
31+
languageOptions: {
32+
globals: {
33+
...globals.browser,
34+
...globals.commonjs,
35+
...globals.node,
36+
},
37+
38+
parser: tsParser,
39+
ecmaVersion: 12,
40+
sourceType: 'commonjs',
41+
},
42+
43+
rules: {
44+
strict: 'error',
45+
'@typescript-eslint/no-non-null-assertion': 'off',
46+
'@typescript-eslint/ban-ts-comment': 'off',
47+
'@typescript-eslint/no-this-alias': [
48+
'error',
49+
{ allowedNames: ['that', 'subThat'] },
50+
],
51+
52+
'@typescript-eslint/naming-convention': [
53+
'warn',
54+
{
55+
selector: 'function',
56+
format: ['camelCase'],
57+
},
58+
],
59+
60+
'@stylistic/semi': 'warn',
61+
semi: 'off',
62+
'getter-return': 'warn',
63+
'no-dupe-args': 'warn',
64+
'no-dupe-else-if': 'warn',
65+
'no-dupe-keys': 'warn',
66+
'no-duplicate-case': 'warn',
67+
'no-empty': 'warn',
68+
'accessor-pairs': 'warn',
69+
'array-callback-return': 'warn',
70+
'block-scoped-var': 'warn',
71+
'class-methods-use-this': 'warn',
72+
complexity: 'warn',
73+
'consistent-return': 'warn',
74+
curly: 'warn',
75+
'default-case': 'warn',
76+
'default-case-last': 'warn',
77+
'default-param-last': 'warn',
78+
'dot-location': 'off',
79+
'dot-notation': 'warn',
80+
eqeqeq: 'warn',
81+
'grouped-accessor-pairs': 'warn',
82+
'guard-for-in': 'off',
83+
'max-classes-per-file': ['warn', 2],
84+
'no-alert': 'warn',
85+
'no-caller': 'warn',
86+
'no-case-declarations': 'off',
87+
'no-constructor-return': 'warn',
88+
'no-div-regex': 'warn',
89+
'no-else-return': 'warn',
90+
'no-empty-function': 'warn',
91+
'no-empty-pattern': 'warn',
92+
'no-eq-null': 'warn',
93+
'no-eval': 'warn',
94+
'no-extend-native': 'off',
95+
'no-extra-bind': 'warn',
96+
'no-extra-label': 'warn',
97+
'no-fallthrough': 'warn',
98+
'no-floating-decimal': 'warn',
99+
'no-global-assign': 'warn',
100+
'no-implicit-coercion': 'warn',
101+
'no-implicit-globals': 'warn',
102+
'no-implied-eval': 'warn',
103+
'no-invalid-this': 'off',
104+
'no-iterator': 'warn',
105+
'no-labels': 'warn',
106+
'no-lone-blocks': 'warn',
107+
'no-loop-func': 'warn',
108+
'no-magic-numbers': 'off',
109+
'no-mixed-spaces-and-tabs': ['warn', 'smart-tabs'],
110+
'no-multi-spaces': 'warn',
111+
'no-multi-str': 'warn',
112+
'no-new': 'warn',
113+
'no-new-func': 'warn',
114+
'no-new-wrappers': 'warn',
115+
'no-octal': 'warn',
116+
'no-octal-escape': 'warn',
117+
'no-param-reassign': 'warn',
118+
'no-proto': 'warn',
119+
'no-redeclare': 'off',
120+
'no-restricted-properties': 'warn',
121+
'no-return-assign': 'warn',
122+
'no-return-await': 'warn',
123+
'no-script-url': 'warn',
124+
'no-self-assign': 'warn',
125+
'no-self-compare': 'warn',
126+
'no-sequences': 'warn',
127+
'no-throw-literal': 'warn',
128+
'no-unmodified-loop-condition': 'warn',
129+
'no-unused-expressions': 'warn',
130+
'no-unused-labels': 'warn',
131+
'no-useless-call': 'warn',
132+
'no-useless-catch': 'warn',
133+
'no-useless-concat': 'warn',
134+
'no-useless-escape': 'warn',
135+
'no-useless-return': 'warn',
136+
'no-void': 'warn',
137+
'no-warning-comments': 'warn',
138+
'no-with': 'warn',
139+
'prefer-named-capture-group': 'warn',
140+
'prefer-promise-reject-errors': 'off',
141+
'prefer-regex-literals': 'warn',
142+
radix: 'warn',
143+
'require-await': 'warn',
144+
'require-unicode-regexp': 'off',
145+
'vars-on-top': 'warn',
146+
'wrap-iife': 'warn',
147+
},
148+
},
149+
];

jest.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
module.exports = {
24
transform: { '^.+\\.ts?$': 'ts-jest' },
35
testEnvironment: 'jsdom',

0 commit comments

Comments
 (0)