Skip to content

Commit 620416c

Browse files
committed
Change coding convention
1 parent e5be9ab commit 620416c

21 files changed

+266
-149
lines changed

Diff for: .eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

Diff for: .eslintrc.json

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
{
2+
"parserOptions": {
3+
"ecmaVersion": "latest",
4+
"sourceType": "module"
5+
},
6+
"env": {
7+
"es6": true,
8+
"node": true,
9+
"browser": true,
10+
"jest": true
11+
},
12+
"globals": {
13+
"globalThis": true
14+
},
15+
"plugins": [],
16+
"overrides": [],
17+
"extends": ["eslint:recommended"],
18+
"rules": {
19+
"arrow-spacing": ["error", { "before": true, "after": true }],
20+
"block-spacing": ["error", "always"],
21+
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
22+
"camelcase": ["error", {
23+
"allow": ["^UNSAFE_"],
24+
"properties": "never",
25+
"ignoreGlobals": true
26+
}],
27+
"comma-dangle": ["error", {
28+
"arrays": "always-multiline",
29+
"objects": "always-multiline",
30+
"imports": "never",
31+
"exports": "never",
32+
"functions": "never"
33+
}],
34+
"comma-spacing": ["error", { "before": false, "after": true }],
35+
"eol-last": "error",
36+
"eqeqeq": ["error", "always", { "null": "ignore" }],
37+
"func-call-spacing": ["error", "never"],
38+
"indent": [
39+
"error",
40+
2,
41+
{
42+
"MemberExpression": 1,
43+
"FunctionDeclaration": {
44+
"body": 1,
45+
"parameters": 2
46+
},
47+
"SwitchCase": 1
48+
}
49+
],
50+
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
51+
"keyword-spacing": ["error", { "before": true, "after": true }],
52+
"lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }],
53+
"max-len": [
54+
"error",
55+
{
56+
"code": 120,
57+
"ignoreTrailingComments": true,
58+
"ignoreComments": true,
59+
"ignoreUrls": true
60+
}
61+
],
62+
"max-lines": [
63+
"error",
64+
{
65+
"max": 360,
66+
"skipBlankLines": true,
67+
"skipComments": false
68+
}
69+
],
70+
"max-lines-per-function": [
71+
"error",
72+
{
73+
"max": 150,
74+
"skipBlankLines": true
75+
}
76+
],
77+
"max-params": ["error", 3],
78+
"no-array-constructor": "error",
79+
"no-mixed-spaces-and-tabs": "error",
80+
"no-multi-spaces": "error",
81+
"no-multi-str": "error",
82+
"no-multiple-empty-lines": [
83+
"error",
84+
{
85+
"max": 1,
86+
"maxEOF": 0
87+
}
88+
],
89+
"no-restricted-syntax": [
90+
"error",
91+
"WithStatement",
92+
"BinaryExpression[operator='in']"
93+
],
94+
"no-trailing-spaces": "error",
95+
"no-use-before-define": [
96+
"error",
97+
{
98+
"functions": true,
99+
"classes": true,
100+
"variables": false
101+
}
102+
],
103+
"no-var": "warn",
104+
"object-curly-spacing": ["error", "always"],
105+
"padded-blocks": [
106+
"error",
107+
{
108+
"blocks": "never",
109+
"switches": "never",
110+
"classes": "never"
111+
}
112+
],
113+
"quotes": ["error", "single"],
114+
"space-before-blocks": ["error", "always"],
115+
"space-before-function-paren": ["error", "always"],
116+
"space-infix-ops": "error",
117+
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
118+
"space-in-parens": ["error", "never"],
119+
"semi": ["error", "never"]
120+
}
121+
}

Diff for: .npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
coverage
3+
.github
4+
pnpm-lock.yaml
5+
examples
6+
test-data

Diff for: CONTRIBUTING.md

-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ This library needs to be simple and flexible to run on multiple platforms such a
1616

1717
## Coding convention
1818

19-
Please follow [standardjs](https://standardjs.com/) style guide.
20-
2119
Make sure your code lints before opening a pull request.
2220

23-
2421
```bash
2522
cd feed-extractor
2623

Diff for: README.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ To read & normalize RSS/ATOM/JSON feed data.
66
![CodeQL](https://github.com/extractus/feed-extractor/workflows/CodeQL/badge.svg)
77
![CI test](https://github.com/extractus/feed-extractor/workflows/ci-test/badge.svg)
88
[![Coverage Status](https://img.shields.io/coveralls/github/extractus/feed-extractor)](https://coveralls.io/github/extractus/feed-extractor?branch=main)
9-
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
10-
11-
### Attention
12-
13-
`feed-reader` has been renamed to `@extractus/feed-extractor` since v6.1.4
9+
[![CodeFactor](https://www.codefactor.io/repository/github/extractus/feed-extractor/badge)](https://www.codefactor.io/repository/github/extractus/feed-extractor)
1410

11+
(This library is derived from [feed-reader](https://www.npmjs.com/package/feed-reader) renamed.)
1512

1613
## Demo
1714

Diff for: build.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const pkg = JSON.parse(readFileSync('./package.json', { encoding: 'utf-8' }))
88

99
rmSync('dist', {
1010
force: true,
11-
recursive: true
11+
recursive: true,
1212
})
1313
mkdirSync('dist')
1414

1515
const buildTime = (new Date()).toISOString()
1616
const comment = [
1717
`// ${pkg.name}@${pkg.version}, by ${pkg.author}`,
1818
`built with esbuild at ${buildTime}`,
19-
`published under ${pkg.license} license`
19+
`published under ${pkg.license} license`,
2020
].join(' - ')
2121

2222
const baseOpt = {
@@ -28,7 +28,7 @@ const baseOpt = {
2828
legalComments: 'none',
2929
minify: false,
3030
sourcemap: false,
31-
write: true
31+
write: true,
3232
}
3333

3434
const esmVersion = {
@@ -37,8 +37,8 @@ const esmVersion = {
3737
format: 'esm',
3838
outfile: 'dist/feed-extractor.esm.js',
3939
banner: {
40-
js: comment
41-
}
40+
js: comment,
41+
},
4242
}
4343
buildSync(esmVersion)
4444

@@ -49,15 +49,15 @@ const cjsVersion = {
4949
mainFields: ['main'],
5050
outfile: 'dist/cjs/feed-extractor.js',
5151
banner: {
52-
js: comment
53-
}
52+
js: comment,
53+
},
5454
}
5555
buildSync(cjsVersion)
5656

5757
const cjspkg = {
5858
name: pkg.name,
5959
version: pkg.version,
60-
main: './feed-extractor.js'
60+
main: './feed-extractor.js',
6161
}
6262

6363
writeFileSync(

Diff for: examples/browser-feed-reader/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const app = express()
88
const loadRemoteFeed = async (url) => {
99
try {
1010
const headers = {
11-
'Accept-Charset': 'utf-8'
11+
'Accept-Charset': 'utf-8',
1212
}
1313
const data = await got(url, { headers }).text()
1414
return data

Diff for: examples/node-feed-reader/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const meta = {
77
service: 'feed-reader',
88
lang: 'javascript',
99
server: 'express',
10-
platform: 'node'
10+
platform: 'node',
1111
}
1212

1313
app.get('/', async (req, res) => {
@@ -20,14 +20,14 @@ app.get('/', async (req, res) => {
2020
includeEntryContent = 'n',
2121
includeOptionalElements = 'n',
2222
useISODateFormat = 'y',
23-
normalization = 'y'
23+
normalization = 'y',
2424
} = req.query
2525

2626
const opts = {
2727
includeEntryContent: includeEntryContent === 'y',
2828
includeOptionalElements: includeOptionalElements === 'y',
2929
useISODateFormat: useISODateFormat !== 'n',
30-
normalization: normalization !== 'n'
30+
normalization: normalization !== 'n',
3131
}
3232

3333
try {
@@ -36,14 +36,14 @@ app.get('/', async (req, res) => {
3636
error: 0,
3737
message: 'feed data has been extracted successfully',
3838
data,
39-
meta
39+
meta,
4040
})
4141
} catch (err) {
4242
return res.json({
4343
error: 1,
4444
message: err.message,
4545
data: null,
46-
meta
46+
meta,
4747
})
4848
}
4949
})

Diff for: package.json

+6-12
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"node": ">= 14"
2626
},
2727
"scripts": {
28-
"lint": "standard .",
29-
"lint:fix": "standard --fix",
28+
"lint": "eslint .",
29+
"lint:fix": "eslint --fix .",
3030
"pretest": "npm run lint",
3131
"test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage=true",
3232
"eval": "node eval",
@@ -36,20 +36,14 @@
3636
"dependencies": {
3737
"bellajs": "^11.1.1",
3838
"cross-fetch": "^3.1.5",
39-
"fast-xml-parser": "^4.0.12",
39+
"fast-xml-parser": "^4.0.13",
4040
"html-entities": "^2.3.3"
4141
},
4242
"devDependencies": {
43-
"esbuild": "^0.16.13",
43+
"esbuild": "^0.16.17",
44+
"eslint": "^8.31.0",
4445
"jest": "^29.3.1",
45-
"nock": "^13.2.9",
46-
"standard": "^17.0.0"
47-
},
48-
"standard": {
49-
"ignore": [
50-
"/dist",
51-
"/examples"
52-
]
46+
"nock": "^13.3.0"
5347
},
5448
"keywords": [
5549
"extractor",

Diff for: reset.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ const dirs = [
1313
'.nyc_output',
1414
'coverage',
1515
'node_modules',
16-
'.nuxt'
16+
'.nuxt',
1717
]
1818

1919
const files = [
2020
'yarn.lock',
2121
'pnpm-lock.yaml',
2222
'package-lock.json',
23-
'coverage.lcov'
23+
'coverage.lcov',
2424
]
2525

2626
dirs.forEach((d) => {

Diff for: src/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ export const read = async (url, options = {}, fetchOptions = {}) => {
2525
useISODateFormat = true,
2626
xmlParserOptions = {},
2727
getExtraFeedFields = () => ({}),
28-
getExtraEntryFields = () => ({})
28+
getExtraEntryFields = () => ({}),
2929
} = options
3030

3131
const opts = {
3232
normalization,
3333
descriptionMaxLen,
3434
useISODateFormat,
3535
getExtraFeedFields,
36-
getExtraEntryFields
36+
getExtraEntryFields,
3737
}
3838

3939
if (type === 'json') {

0 commit comments

Comments
 (0)