Skip to content

Commit 2ccf13e

Browse files
authored
eslint fixes (#56)
1 parent 4476837 commit 2ccf13e

File tree

16 files changed

+116
-104
lines changed

16 files changed

+116
-104
lines changed

.eslintrc.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ module.exports = {
44
extends: [
55
"eslint:recommended",
66
"plugin:node/recommended",
7-
"plugin:prettier/recommended"
7+
"plugin:prettier/recommended",
88
],
99
env: {
10-
node: true
10+
node: true,
1111
},
1212
parserOptions: {
13-
ecmaVersion: 8
13+
ecmaVersion: 8,
1414
},
1515
rules: {
1616
"prettier/prettier": "error",
@@ -19,6 +19,7 @@ module.exports = {
1919
"no-template-curly-in-string": "error",
2020
"no-caller": "error",
2121
"no-control-regex": "off",
22+
"no-async-promise-executor": "off",
2223
yoda: "error",
2324
eqeqeq: "error",
2425
"global-require": "off",
@@ -30,8 +31,8 @@ module.exports = {
3031
"no-unused-vars": [
3132
"error",
3233
{
33-
args: "none"
34-
}
34+
args: "none",
35+
},
3536
],
3637
"no-unsafe-negation": "error",
3738
"no-loop-func": "warn",
@@ -47,19 +48,19 @@ module.exports = {
4748
class: "DONTUSE",
4849
inheritdoc: "DONTUSE",
4950
description: "DONTUSE",
50-
readonly: "DONTUSE"
51+
readonly: "DONTUSE",
5152
},
5253
preferType: {
53-
"*": "any"
54+
"*": "any",
5455
},
55-
requireReturnType: true
56-
}
56+
requireReturnType: true,
57+
},
5758
],
5859
"node/no-unsupported-features": "error",
5960
"node/no-deprecated-api": "error",
6061
"node/no-missing-import": "error",
6162
"node/no-unpublished-bin": "error",
6263
"node/no-unpublished-require": "error",
63-
"node/process-exit-as-throw": "error"
64-
}
64+
"node/process-exit-as-throw": "error",
65+
},
6566
};

.github/workflows/build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: build
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [12.x]
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v1
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
- run: npm ci
28+
- run: npm run eslint
29+
env:
30+
CI: true

.travis.yml

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# powerbi-visuals-webpack-plugin
22

3-
[![npm version](https://img.shields.io/npm/v/powerbi-visuals-webpack-plugin.svg)](https://www.npmjs.com/package/powerbi-visuals-webpack-plugin) [![npm](https://img.shields.io/npm/dm/powerbi-visuals-webpack-plugin.svg)](https://www.npmjs.com/package/powerbi-visuals-webpack-plugin)
3+
![Build](https://github.com/microsoft/powerbi-visuals-webpack-plugin/workflows/build/badge.svg) [![npm version](https://img.shields.io/npm/v/powerbi-visuals-webpack-plugin.svg)](https://www.npmjs.com/package/powerbi-visuals-webpack-plugin) [![npm](https://img.shields.io/npm/dm/powerbi-visuals-webpack-plugin.svg)](https://www.npmjs.com/package/powerbi-visuals-webpack-plugin)
44

55
This plugin allows developing custom visuals by using webpack to build a visual package.
66

constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
ENCODING: "utf-8"
2+
ENCODING: "utf-8",
33
};

extractor/capabilities.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require("path");
33
const fs = require("fs-extra");
44
const logger = require("../logger");
55

6-
const getSchema = async function(options) {
6+
const getSchema = async function (options) {
77
if (options.capabilitiesSchema)
88
return Promise.resolve(options.capabilitiesSchema);
99

@@ -12,7 +12,7 @@ const getSchema = async function(options) {
1212
);
1313
};
1414

15-
module.exports = async function(options) {
15+
module.exports = async function (options) {
1616
let getContent;
1717
switch (typeof options.capabilities) {
1818
case "string": {
@@ -34,7 +34,7 @@ module.exports = async function(options) {
3434
const ajv = new Ajv({ extendRefs: true });
3535
const valid = ajv.validate(schema, json);
3636
if (valid) return json;
37-
ajv.errors.forEach(error =>
37+
ajv.errors.forEach((error) =>
3838
logger.error(error.message, error.dataPath)
3939
);
4040

extractor/css.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const RawSource = require("webpack-sources/lib/RawSource");
33

44
const { ENCODING } = require("../constants");
55

6-
module.exports = async function(options, { assets }) {
6+
module.exports = async function (options, { assets }) {
77
let chunkContent, result;
88

99
for (let asset in assets) {
@@ -17,7 +17,7 @@ module.exports = async function(options, { assets }) {
1717
if (!chunkContent) {
1818
if (options.cssStyles) {
1919
result = fs.readFile(options.cssStyles, {
20-
encoding: ENCODING
20+
encoding: ENCODING,
2121
});
2222
} else {
2323
assets["visual.css"] = new RawSource("");

extractor/dependencies.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require("path");
33
const fs = require("fs-extra");
44
const logger = require("../logger");
55

6-
const getSchema = async function(options) {
6+
const getSchema = async function (options) {
77
if (options.dependenciesSchema)
88
return Promise.resolve(options.dependenciesSchema);
99

@@ -12,15 +12,15 @@ const getSchema = async function(options) {
1212
);
1313
};
1414

15-
module.exports = async function(options) {
15+
module.exports = async function (options) {
1616
if (!options.dependencies) return Promise.resolve(null);
1717

1818
let getContent;
1919
switch (typeof options.dependencies) {
2020
case "string": {
2121
getContent = fs
2222
.readJson(path.join(process.cwd(), options.dependencies))
23-
.catch(err => {
23+
.catch((err) => {
2424
if (err.code === "ENOENT") {
2525
logger.warn(
2626
`No such file or directory: ${path.join(
@@ -46,7 +46,7 @@ module.exports = async function(options) {
4646
const ajv = new Ajv({ extendRefs: true });
4747
const valid = ajv.validate(schema, json);
4848
if (valid) return json;
49-
ajv.errors.forEach(error =>
49+
ajv.errors.forEach((error) =>
5050
logger.error(error.message, error.dataPath)
5151
);
5252

extractor/js.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ const RawSource = require("webpack-sources/lib/RawSource");
44
const { ENCODING } = require("../constants");
55
const logger = require("../logger");
66

7-
const appendExternalJS = async function(externalJS) {
7+
const appendExternalJS = async function (externalJS) {
88
return Promise.all(
9-
externalJS.map(path =>
10-
fs.readFile(path, ENCODING).catch(err => {
9+
externalJS.map((path) =>
10+
fs.readFile(path, ENCODING).catch((err) => {
1111
logger.warn(err.message);
1212
})
1313
)
14-
).then(results => results.join(""));
14+
).then((results) => results.join(""));
1515
};
1616

17-
module.exports = async function(options, compilation) {
17+
module.exports = async function (options, compilation) {
1818
let path, chunkContent;
1919
const sourcePromises = [];
2020

@@ -33,7 +33,7 @@ module.exports = async function(options, compilation) {
3333
}
3434
sourcePromises.push(Promise.resolve(chunkContent));
3535

36-
return Promise.all(sourcePromises).then(chunks => {
36+
return Promise.all(sourcePromises).then((chunks) => {
3737
const content = chunks.join("\n");
3838
compilation.assets[path] = new RawSource(content);
3939
return content;

extractor/localization.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@ const path = require("path");
22
const fs = require("fs-extra");
33
const { ENCODING } = require("../constants");
44

5-
const parseFromProperty = async function(options) {
5+
const parseFromProperty = async function (options) {
66
if (!options.stringResources || !options.stringResources.length) return;
77
return Promise.all(
8-
options.stringResources.map(resourcePath => {
8+
options.stringResources.map((resourcePath) => {
99
return fs
1010
.readJSON(path.join(process.cwd(), resourcePath), {
1111
throws: false,
12-
encoding: ENCODING
12+
encoding: ENCODING,
1313
})
14-
.catch(err => {
14+
.catch((err) => {
1515
console.error(err);
1616
return;
1717
});
1818
})
1919
);
2020
};
2121

22-
const parseFromFolder = async function(options) {
22+
const parseFromFolder = async function (options) {
2323
const resourcesDir = path.join(process.cwd(), "stringResources");
2424

2525
return fs.readdir(resourcesDir).then(
26-
folders =>
26+
(folders) =>
2727
Promise.all(
28-
folders.map(folder => {
28+
folders.map((folder) => {
2929
return fs
3030
.readJson(
3131
path.join(
@@ -35,14 +35,14 @@ const parseFromFolder = async function(options) {
3535
),
3636
{
3737
throws: false,
38-
encoding: ENCODING
38+
encoding: ENCODING,
3939
}
4040
)
41-
.then(resource => ({
41+
.then((resource) => ({
4242
locale: folder,
43-
values: resource
43+
values: resource,
4444
}))
45-
.catch(err => {
45+
.catch((err) => {
4646
console.error(err);
4747
return;
4848
});
@@ -52,20 +52,20 @@ const parseFromFolder = async function(options) {
5252
);
5353
};
5454

55-
module.exports = async function(options) {
55+
module.exports = async function (options) {
5656
if (options.devMode) {
5757
return;
5858
}
5959
return Promise.all([
6060
parseFromProperty(options),
61-
parseFromFolder(options)
61+
parseFromFolder(options),
6262
]).then(([source1 = [], source2 = []]) => {
6363
const stringResources = Object.create(null);
64-
source1.forEach(res => {
64+
source1.forEach((res) => {
6565
if (!res) return;
6666
stringResources[res.locale] = res.values;
6767
});
68-
source2.forEach(res => {
68+
source2.forEach((res) => {
6969
if (!res) return;
7070

7171
if (stringResources[res.locale]) {

extractor/scriptVisual.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const { ENCODING } = require("../constants");
44

55
const MAX_IMPORT_MODULES = 100;
66

7-
const getContent = async filePath => {
7+
const getContent = async (filePath) => {
88
const Pattern4FileName = /^[^#\n]*source\s*?\(\s*?['|"]([^()'"]*)['|"]\s*?\)/m;
99

10-
return fs.readFile(filePath, ENCODING).then(async content => {
10+
return fs.readFile(filePath, ENCODING).then(async (content) => {
1111
let replaceCount = 0;
1212
let matchListFileName = Pattern4FileName.exec(content);
1313
while (
@@ -28,7 +28,7 @@ const getContent = async filePath => {
2828
});
2929
};
3030

31-
const isScriptVisual = capabilities => {
31+
const isScriptVisual = (capabilities) => {
3232
return (
3333
capabilities &&
3434
capabilities.dataViewMappings &&
@@ -37,7 +37,7 @@ const isScriptVisual = capabilities => {
3737
);
3838
};
3939

40-
const getFileExtension = providerName => {
40+
const getFileExtension = (providerName) => {
4141
providerName = providerName.toLowerCase();
4242
switch (providerName) {
4343
case "r":
@@ -71,5 +71,5 @@ const patchCababilities = async (options, capabilities) => {
7171
module.exports = {
7272
getContent,
7373
isScriptVisual,
74-
patchCababilities
74+
patchCababilities,
7575
};

0 commit comments

Comments
 (0)