Skip to content

Commit 4200642

Browse files
committed
chore: apply ESLint fixes
1 parent e3df47d commit 4200642

36 files changed

+1213
-814
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc

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

.github/workflows/feature.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
jobs:
22
test:
3-
runs-on: ubuntu-latest
43
environment: release
54
name: Test
5+
runs-on: ubuntu-latest
66
steps:
77
- name: setup repository
88
uses: actions/checkout@v3
@@ -11,7 +11,7 @@ jobs:
1111
- name: setup node.js
1212
uses: actions/setup-node@v3
1313
with:
14-
node-version: "18"
14+
node-version: '18'
1515
- run: npm ci
1616
- run: npm run lint
1717
- run: npm run test

.github/workflows/main.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
jobs:
22
test:
3-
runs-on: ubuntu-latest
43
environment: release
54
name: Test
5+
runs-on: ubuntu-latest
66
steps:
77
- name: setup repository
88
uses: actions/checkout@v3
@@ -11,15 +11,15 @@ jobs:
1111
- name: setup node.js
1212
uses: actions/setup-node@v3
1313
with:
14-
node-version: "18"
14+
node-version: '18'
1515
- run: npm ci
1616
- run: npm run lint
1717
- run: npm run test
1818
- run: npm run build
19-
- run: npx semantic-release
20-
env:
19+
- env:
2120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2221
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
22+
run: npx semantic-release
2323
name: Test, build and release
2424
on:
2525
push:

eslint.config.cjs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const auto = require('eslint-config-canonical/configurations/auto');
2+
const ava = require('eslint-config-canonical/configurations/ava');
3+
const node = require('eslint-config-canonical/configurations/node');
4+
5+
module.exports = [
6+
...auto,
7+
ava.recommended,
8+
{
9+
files: ['**/*.cjs'],
10+
...node.recommended,
11+
},
12+
{
13+
rules: {
14+
'@typescript-eslint/no-explicit-any': 0,
15+
'func-style': 0,
16+
'id-length': 0,
17+
'no-template-curly-in-string': 0,
18+
'regexp/no-unused-capturing-group': 0,
19+
'regexp/optimal-quantifier-concatenation': 0,
20+
'require-unicode-regexp': 0,
21+
},
22+
},
23+
{
24+
ignores: [
25+
'package-lock.json',
26+
'dist',
27+
'node_modules',
28+
'src/pg-formatter',
29+
'*.log',
30+
'.*',
31+
'!.github',
32+
'!.gitignore',
33+
'!.husky',
34+
'!.releaserc',
35+
],
36+
},
37+
];

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"benny": "^3.7.1",
3333
"coveralls": "^3.1.1",
3434
"del-cli": "^4.0.1",
35-
"eslint": "^7.32.0",
36-
"eslint-config-canonical": "^28.0.0",
35+
"eslint": "^9.17.0",
36+
"eslint-config-canonical": "^44.3.36",
3737
"faker": "^5.5.3",
3838
"husky": "^7.0.4",
3939
"npm-watch": "^0.11.0",
@@ -55,18 +55,18 @@
5555
"type": "git",
5656
"url": "[email protected]:gajus/liqe.git"
5757
},
58-
"watch": {
59-
"compile-parser": "src/grammar.ne"
60-
},
6158
"scripts": {
62-
"watch": "npm-watch",
6359
"benchmark": "ts-node --transpile-only test/benchmark.ts",
6460
"build": "del-cli ./dist && tsc",
6561
"compile-parser": "nearleyc src/grammar.ne --out ./src/grammar.ts && sed -i '' 's/loc?: number/loc: number/g' src/grammar.ts",
6662
"dev": "tsc --watch",
6763
"lint": "eslint ./src ./test && tsc --noEmit",
68-
"test": "NODE_ENV=test ava --serial --verbose"
64+
"test": "NODE_ENV=test ava --serial --verbose",
65+
"watch": "npm-watch"
6966
},
7067
"typings": "./dist/src/Liqe.d.ts",
71-
"version": "1.0.0"
68+
"version": "1.0.0",
69+
"watch": {
70+
"compile-parser": "src/grammar.ne"
71+
}
7272
}

src/Liqe.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
export {
2-
filter,
3-
} from './filter';
4-
export {
5-
highlight,
6-
} from './highlight';
7-
export {
8-
parse,
9-
} from './parse';
10-
export {
11-
test,
12-
} from './test';
1+
export { LiqeError, SyntaxError } from './errors';
2+
export { filter } from './filter';
3+
export { highlight } from './highlight';
4+
export { isSafeUnquotedExpression } from './isSafeUnquotedExpression';
5+
export { parse } from './parse';
6+
export { serialize } from './serialize';
7+
export { test } from './test';
138
export {
149
BooleanOperatorToken,
1510
ComparisonOperatorToken,
@@ -29,13 +24,3 @@ export {
2924
TagToken,
3025
UnaryOperatorToken,
3126
} from './types';
32-
export {
33-
LiqeError,
34-
SyntaxError,
35-
} from './errors';
36-
export {
37-
serialize,
38-
} from './serialize';
39-
export {
40-
isSafeUnquotedExpression,
41-
} from './isSafeUnquotedExpression';

src/convertWildcardToRegex.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ const WILDCARD_RULE = /(\*+)|(\?)/g;
22

33
export const convertWildcardToRegex = (pattern: string): RegExp => {
44
return new RegExp(
5-
pattern
6-
.replace(WILDCARD_RULE, (_match, p1) => {
7-
return p1 ? '(.+?)' : '(.)';
8-
}),
5+
pattern.replaceAll(WILDCARD_RULE, (_match, p1) => {
6+
return p1 ? '(.+?)' : '(.)';
7+
}),
98
);
109
};

src/createGetValueFunctionBody.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import {
2-
isSafePath,
3-
} from './isSafePath';
1+
import { isSafePath } from './isSafePath';
42

53
export const createGetValueFunctionBody = (path: string): string => {
64
if (!isSafePath(path)) {
@@ -9,7 +7,5 @@ export const createGetValueFunctionBody = (path: string): string => {
97

108
const body = 'return subject' + path;
119

12-
return body
13-
.replace(/(\.(\d+))/g, '.[$2]')
14-
.replace(/\./g, '?.');
10+
return body.replaceAll(/(\.(\d+))/g, '.[$2]').replaceAll('.', '?.');
1511
};

src/createStringTest.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
import {
2-
convertWildcardToRegex,
3-
} from './convertWildcardToRegex';
4-
import {
5-
escapeRegexString,
6-
} from './escapeRegexString';
7-
import {
8-
parseRegex,
9-
} from './parseRegex';
10-
import type {
11-
LiqeQuery,
12-
} from './types';
1+
import { convertWildcardToRegex } from './convertWildcardToRegex';
2+
import { escapeRegexString } from './escapeRegexString';
3+
import { parseRegex } from './parseRegex';
4+
import { type LiqeQuery } from './types';
135

146
type RegExpCache = Record<string, RegExp>;
157

@@ -19,10 +11,11 @@ const createRegexTest = (regexCache: RegExpCache, regex: string) => {
1911
if (regexCache[regex]) {
2012
rule = regexCache[regex];
2113
} else {
22-
rule = regexCache[regex] = parseRegex(regex);
14+
rule = parseRegex(regex);
15+
regexCache[regex] = rule;
2316
}
2417

25-
return (subject: string): string | false => {
18+
return (subject: string): false | string => {
2619
return subject.match(rule)?.[0] ?? false;
2720
};
2821
};
@@ -32,9 +25,7 @@ export const createStringTest = (regexCache: RegExpCache, ast: LiqeQuery) => {
3225
throw new Error('Expected a tag expression.');
3326
}
3427

35-
const {
36-
expression,
37-
} = ast;
28+
const { expression } = ast;
3829

3930
if (expression.type === 'RangeExpression') {
4031
throw new Error('Unexpected range expression.');
@@ -50,9 +41,18 @@ export const createStringTest = (regexCache: RegExpCache, ast: LiqeQuery) => {
5041

5142
const value = String(expression.value);
5243

53-
if ((value.includes('*') || value.includes('?')) && expression.quoted === false) {
54-
return createRegexTest(regexCache, String(convertWildcardToRegex(value)) + 'ui');
44+
if (
45+
(value.includes('*') || value.includes('?')) &&
46+
expression.quoted === false
47+
) {
48+
return createRegexTest(
49+
regexCache,
50+
String(convertWildcardToRegex(value)) + 'ui',
51+
);
5552
} else {
56-
return createRegexTest(regexCache, '/(' + escapeRegexString(value) + ')/' + (expression.quoted ? 'u' : 'ui'));
53+
return createRegexTest(
54+
regexCache,
55+
'/(' + escapeRegexString(value) + ')/' + (expression.quoted ? 'u' : 'ui'),
56+
);
5757
}
5858
};

src/errors.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
/* eslint-disable fp/no-class */
2-
3-
import {
4-
ExtendableError,
5-
} from 'ts-error';
1+
import { ExtendableError } from 'ts-error';
62

73
export class LiqeError extends ExtendableError {}
84

95
export class SyntaxError extends LiqeError {
10-
public constructor (
6+
public constructor(
117
public message: string,
128
public offset: number,
139
public line: number,

src/escapeRegexString.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ const ESCAPE_RULE = /[$()*+.?[\\\]^{|}]/g;
22
const DASH_RULE = /-/g;
33

44
export const escapeRegexString = (subject: string): string => {
5-
return subject
6-
.replace(ESCAPE_RULE, '\\$&')
7-
.replace(DASH_RULE, '\\x2d');
5+
return subject.replaceAll(ESCAPE_RULE, '\\$&').replaceAll(DASH_RULE, '\\x2d');
86
};

src/filter.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
import {
2-
internalFilter,
3-
} from './internalFilter';
4-
import type {
5-
LiqeQuery,
6-
} from './types';
1+
import { internalFilter } from './internalFilter';
2+
import { type LiqeQuery } from './types';
73

84
export const filter = <T extends Object>(
95
ast: LiqeQuery,
106
data: readonly T[],
117
): readonly T[] => {
12-
return internalFilter(
13-
ast,
14-
data,
15-
);
8+
return internalFilter(ast, data);
169
};

0 commit comments

Comments
 (0)