Skip to content

Commit

Permalink
fix: eslint doesnt work (#4379)
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent authored Jun 6, 2024
1 parent 1af834d commit 231709f
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 99 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

48 changes: 48 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
extends: 'airbnb-base',
env: {
node: true,
},
parserOptions: {
ecmaVersion: 2020,
},
rules: {
'func-names': 0,
'no-use-before-define': 0,
'no-unused-vars': 0,
'no-underscore-dangle': 0,
'no-undef': 0,
'prefer-destructuring': 0,
'no-param-reassign': 0,
'max-len': 0,
camelcase: 0,
'no-shadow': 0,
'consistent-return': 0,
'no-console': 0,
'global-require': 0,
'class-methods-use-this': 0,
'no-plusplus': 0,
'no-return-assign': 0,
'prefer-rest-params': 0,
'no-useless-escape': 0,
'no-restricted-syntax': 0,
'no-unused-expressions': 0,
'guard-for-in': 0,
'no-multi-assign': 0,
'require-yield': 0,
'prefer-spread': 0,
'import/no-dynamic-require': 0,
'no-continue': 0,
'no-mixed-operators': 0,
'default-case': 0,
'import/no-extraneous-dependencies': 0,
'no-cond-assign': 0,
'import/no-unresolved': 0,
'no-await-in-loop': 0,
'arrow-body-style': 0,
'no-loop-func': 0,
'arrow-parens': 0,
'default-param-last': 0,
},
ignorePatterns: ['test/data/output', 'lib/css2xpath/*'],
};
47 changes: 0 additions & 47 deletions .eslintrc.json

This file was deleted.

4 changes: 3 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ updates:
versions: [">=5.0"]
- dependency-name: "apollo-server-express"
versions: [">=3.0"]

- dependency-name: "eslint"
versions: [ ">8.57.0" ]

2 changes: 1 addition & 1 deletion .hound.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
eslint:
enabled: true
config_file: .eslintrc.json
config_file: .eslintrc.js
6 changes: 3 additions & 3 deletions lib/command/gherkin/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function (genPath) {

if (!configFile) {
output.error(
"Can't initialize Gherkin. This command must be run in an already initialized project."
"Can't initialize Gherkin. This command must be run in an already initialized project.",
);
process.exit(1);
}
Expand Down Expand Up @@ -65,12 +65,12 @@ module.exports = function (genPath) {

if (safeFileWrite(path.join(dir, `steps.${extension}`), stepsFile)) {
output.success(
`Created sample steps file: step_definitions/steps.${extension}`
`Created sample steps file: step_definitions/steps.${extension}`,
);
}

config.gherkin = {
features: "./features/*.feature",
features: './features/*.feature',
steps: [`./step_definitions/steps.${extension}`],
};

Expand Down
4 changes: 2 additions & 2 deletions lib/command/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function updateConfig(testsPath, config, extension) {
const msg = `codecept.conf.${extension} config can\'t be updated automatically`;
console.log();
console.log(`${output.colors.bold.red(msg)}`);
console.log(`${output.colors.bold.red("Please update it manually:")}`);
console.log(`${output.colors.bold.red('Please update it manually:')}`);
console.log();
console.log(config);
console.log();
Expand Down Expand Up @@ -114,4 +114,4 @@ module.exports.findConfigFile = (testsPath) => {
}
}
return null;
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"contributor-faces": "1.1.0",
"documentation": "12.3.0",
"electron": "30.0.3",
"eslint": "9.2.0",
"eslint": "8.57.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-mocha": "10.4.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/** @type {CodeceptJS.MainConfig} */
exports.config = {
tests: "./*_test.js",
output: "./output",
tests: './*_test.js',
output: './output',
helpers: {
Playwright: {
browser: "chromium",
url: "http://localhost",
browser: 'chromium',
url: 'http://localhost',
show: true,
},
},
include: {
I: "./steps_file.js",
I: './steps_file.js',
},
name: "CodeceptJS",
name: 'CodeceptJS',
};
4 changes: 2 additions & 2 deletions test/plugin/plugin_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('CodeceptJS plugin', function () {
expect.arrayContaining([
expect.stringContaining('writing output/coverage'),
expect.stringContaining('generated coverage reports:'),
expect.stringContaining('output/coverage/index.html')
expect.stringContaining('output/coverage/index.html'),
]),
);
expect(err).toBeFalsy();
Expand All @@ -54,7 +54,7 @@ describe('CodeceptJS plugin', function () {
expect.arrayContaining([
expect.stringContaining('writing output/coverage'),
expect.stringContaining('generated coverage reports:'),
expect.stringContaining('output/coverage/index.html')
expect.stringContaining('output/coverage/index.html'),
]),
);
expect(err).toBeFalsy();
Expand Down
72 changes: 38 additions & 34 deletions test/runner/gherkin_test.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,93 @@
const assert = require("assert");
const path = require("path");
const fs = require("fs");
const exec = require("child_process").exec;
const assert = require('assert');
const path = require('path');
const fs = require('fs');
const exec = require('child_process').exec;

const runner = path.join(__dirname, "/../../bin/codecept.js");
const codecept_dir = path.join(__dirname, "/../data/sandbox/configs/gherkin/");
const runner = path.join(__dirname, '/../../bin/codecept.js');
const codecept_dir = path.join(__dirname, '/../data/sandbox/configs/gherkin/');

describe("gherkin bdd commands", () => {
describe("bdd:init", () => {
let codecept_dir_js = path.join(codecept_dir, "config_js");
let codecept_dir_ts = path.join(codecept_dir, "config_ts");
describe('gherkin bdd commands', () => {
describe('bdd:init', () => {
const codecept_dir_js = path.join(codecept_dir, 'config_js');
const codecept_dir_ts = path.join(codecept_dir, 'config_ts');

beforeEach(() => {
fs.copyFileSync(
path.join(codecept_dir_js, "codecept.conf.init.js"),
path.join(codecept_dir_js, "codecept.conf.js")
path.join(codecept_dir_js, 'codecept.conf.init.js'),
path.join(codecept_dir_js, 'codecept.conf.js'),
);
fs.copyFileSync(
path.join(codecept_dir_ts, "codecept.conf.init.ts"),
path.join(codecept_dir_ts, "codecept.conf.ts")
path.join(codecept_dir_ts, 'codecept.conf.init.ts'),
path.join(codecept_dir_ts, 'codecept.conf.ts'),
);
});

afterEach(() => {
try {
fs.rmSync(path.join(codecept_dir_js, "codecept.conf.js"));
fs.rmSync(path.join(codecept_dir_js, "features"), {
fs.rmSync(path.join(codecept_dir_js, 'codecept.conf.js'));
fs.rmSync(path.join(codecept_dir_js, 'features'), {
recursive: true,
});
fs.rmSync(path.join(codecept_dir_js, "step_definitions"), {
fs.rmSync(path.join(codecept_dir_js, 'step_definitions'), {
recursive: true,
});
} catch (e) {}
} catch (e) {
// catch some error
}
try {
fs.rmSync(path.join(codecept_dir_ts, "codecept.conf.ts"));
fs.rmSync(path.join(codecept_dir_ts, "features"), {
fs.rmSync(path.join(codecept_dir_ts, 'codecept.conf.ts'));
fs.rmSync(path.join(codecept_dir_ts, 'features'), {
recursive: true,
});
fs.rmSync(path.join(codecept_dir_ts, "step_definitions"), {
fs.rmSync(path.join(codecept_dir_ts, 'step_definitions'), {
recursive: true,
});
} catch (e) {}
} catch (e) {
// catch some error
}
});

[
{
codecept_dir_test: codecept_dir_js,
extension: "js",
extension: 'js',
},
{
codecept_dir_test: codecept_dir_ts,
extension: "ts",
extension: 'ts',
},
].forEach(({ codecept_dir_test, extension }) => {
it(`prepare CodeceptJS to run feature files (codecept.conf.${extension})`, (done) => {
exec(`${runner} gherkin:init ${codecept_dir_test}`, (err, stdout) => {
let dir = path.join(codecept_dir_test, "features");
let dir = path.join(codecept_dir_test, 'features');

stdout.should.include(
"Initializing Gherkin (Cucumber BDD) for CodeceptJS"
'Initializing Gherkin (Cucumber BDD) for CodeceptJS',
);
stdout.should.include(
`Created ${dir}, place your *.feature files in it`
`Created ${dir}, place your *.feature files in it`,
);
stdout.should.include(
"Created sample feature file: features/basic.feature"
'Created sample feature file: features/basic.feature',
);

dir = path.join(codecept_dir_test, "step_definitions");
dir = path.join(codecept_dir_test, 'step_definitions');
stdout.should.include(
`Created ${dir}, place step definitions into it`
`Created ${dir}, place step definitions into it`,
);
stdout.should.include(
`Created sample steps file: step_definitions/steps.${extension}`
`Created sample steps file: step_definitions/steps.${extension}`,
);
assert(!err);

const configResult = fs
.readFileSync(
path.join(codecept_dir_test, `codecept.conf.${extension}`)
path.join(codecept_dir_test, `codecept.conf.${extension}`),
)
.toString();
configResult.should.contain(`features: './features/*.feature'`);
configResult.should.contain('features: \'./features/*.feature\'');
configResult.should.contain(
`steps: ['./step_definitions/steps.${extension}']`
`steps: ['./step_definitions/steps.${extension}']`,
);
done();
});
Expand Down

0 comments on commit 231709f

Please sign in to comment.