Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
version: 2.1

supported-eslint-versions: &supported-eslint-versions ["local", "7"]

jobs:
build:
parameters:
eslint-version:
type: string
description: >
Overrides the installed version of ESLint. When set to "local" the version of ESLint set
frozen in the yarn.lock is used.
default: "local"
docker:
- image: circleci/node

Expand All @@ -19,7 +28,14 @@ jobs:
paths:
- node_modules
key: v1-dependencies-{{ checksum "yarn.lock" }}

- when:
condition:
not:
equal: [<<parameters.eslint-version>>, "local"]
steps:
- run:
name: Override version of eslint@<<parameters.eslint-version>>
command: yarn add eslint@<<parameters.eslint-version>> --dev
- run: yarn format:check
- run: yarn lint
- run: yarn test
Expand All @@ -28,4 +44,7 @@ jobs:
workflows:
build_and_test:
jobs:
- build
- build:
matrix:
parameters:
eslint-version: *supported-eslint-versions
27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,26 @@
"test": "mocha"
},
"dependencies": {
"@babel/core": "~7.15.5",
"@babel/eslint-parser": "~7.15.7",
"@babel/core": "~7.16.0",
"@babel/eslint-parser": "~7.16.0",
"eslint-restricted-globals": "~0.2.0"
},
"devDependencies": {
"@lwc/eslint-plugin-lwc": "^1.1.0",
"@salesforce/eslint-plugin-lightning": "^0.1.0",
"eslint": "^7.26.0",
"eslint-plugin-import": "^2.23.2",
"eslint-plugin-jest": "^24.5.2",
"husky": "^7.0.0",
"lint-staged": "^11.2.0",
"mocha": "^9.1.2",
"prettier": "^2.4.1"
"@lwc/eslint-plugin-lwc": "^1.1.1",
"@salesforce/eslint-plugin-lightning": "^1.0.0",
"eslint": "^8.2.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.2.4",
"husky": "^7.0.4",
"lint-staged": "^11.2.6",
"mocha": "^9.1.3",
"prettier": "^2.4.1",
"semver": "^7.3.5"
},
"peerDependencies": {
"@lwc/eslint-plugin-lwc": "^1.0.0",
"@salesforce/eslint-plugin-lightning": "^0.1.0",
"eslint": "^7",
"@salesforce/eslint-plugin-lightning": "^1.0.0",
"eslint": "^7 || ^8",
"eslint-plugin-import": "*",
"eslint-plugin-jest": "*"
},
Expand Down
24 changes: 12 additions & 12 deletions test/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,36 @@ describe('base config', () => {
unlinkConfig();
});

it('should load properly base config', () => {
const cli = new eslint.CLIEngine({
it('should load properly base config', async () => {
const cli = new eslint.ESLint({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useEslintrc: false,
baseConfig: {
extends: '@salesforce/eslint-config-lwc/base',
},
});

const report = cli.executeOnText(`
const results = await cli.lintText(`
import { api } from 'lwc';
class Foo {
@api({ param: true })
foo;
}
`);

const { messages } = report.results[0];
const { messages } = results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@lwc/lwc/valid-api');
});

it('should include @lwc/lwc/no-unknown-wire-adapters rule', () => {
const cli = new eslint.CLIEngine({
it('should include @lwc/lwc/no-unknown-wire-adapters rule', async () => {
const cli = new eslint.ESLint({
useEslintrc: false,
baseConfig: {
extends: '@salesforce/eslint-config-lwc/base',
},
});

const report = cli.executeOnText(`
const results = await cli.lintText(`
import { wire } from 'lwc';
import { Baz } from 'c/cmp';
class Foo {
Expand All @@ -58,20 +58,20 @@ describe('base config', () => {
}
`);

const { messages } = report.results[0];
const { messages } = results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@lwc/lwc/no-unknown-wire-adapters');
});

it('should include @lwc/lwc/no-unexpected-wire-adapter-usages', () => {
const cli = new eslint.CLIEngine({
it('should include @lwc/lwc/no-unexpected-wire-adapter-usages', async () => {
const cli = new eslint.ESLint({
useEslintrc: false,
baseConfig: {
extends: '@salesforce/eslint-config-lwc/base',
},
});

const report = cli.executeOnText(`
const results = await cli.lintText(`
import { wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
const reference = CurrentPageReference;
Expand All @@ -81,7 +81,7 @@ describe('base config', () => {
}
`);

const { messages } = report.results[0];
const { messages } = results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@lwc/lwc/no-unexpected-wire-adapter-usages');
});
Expand Down
8 changes: 4 additions & 4 deletions test/extended.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('extended config', () => {
unlinkConfig();
});

it('should load properly extended config', () => {
const cli = new eslint.CLIEngine({
it('should load properly extended config', async () => {
const cli = new eslint.ESLint({
useEslintrc: false,
baseConfig: {
extends: '@salesforce/eslint-config-lwc/extended',
Expand All @@ -35,13 +35,13 @@ describe('extended config', () => {
},
});

const report = cli.executeOnText(`
const results = await cli.lintText(`
export function sum(...args) {
return args.reduce((acc, val) => acc + val, 0);
}
`);

const { messages } = report.results[0];
const { messages } = results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@lwc/lwc/no-rest-parameter');
});
Expand Down
16 changes: 8 additions & 8 deletions test/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('i18n configs', () => {
unlinkConfig();
});

it('should load properly i18n config with other set', () => {
const cli = new eslint.CLIEngine({
it('should load properly i18n config with other set', async () => {
const cli = new eslint.ESLint({
useEslintrc: false,
baseConfig: {
extends: [
Expand All @@ -31,32 +31,32 @@ describe('i18n configs', () => {
},
});

const report = cli.executeOnText(`
const results = await cli.lintText(`
var moment = require('moment');
var a = moment('2016-01-01');
a.format();
`);

const { messages } = report.results[0];
const { messages } = results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@salesforce/lightning/no-moment');
});

it('extended set should include @salesforce/lightning/no-moment rule', () => {
const cli = new eslint.CLIEngine({
it('extended set should include @salesforce/lightning/no-moment rule', async () => {
const cli = new eslint.ESLint({
useEslintrc: false,
baseConfig: {
extends: '@salesforce/eslint-config-lwc/i18n',
},
});

const report = cli.executeOnText(`
const results = await cli.lintText(`
var moment = require('moment');
var a = moment('2016-01-01');
a.format();
`);

const { messages } = report.results[0];
const { messages } = results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@salesforce/lightning/no-moment');
});
Expand Down
8 changes: 4 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ describe('default config', () => {
unlinkConfig();
});

it('should load properly base config when not specifying the config name', () => {
const cli = new eslint.CLIEngine({
it('should load properly base config when not specifying the config name', async () => {
const cli = new eslint.ESLint({
useEslintrc: false,
baseConfig: {
extends: '@salesforce/eslint-config-lwc',
},
});

const report = cli.executeOnText(`
const results = await cli.lintText(`
import { api } from 'lwc';
class Foo {
@api({ param: true })
foo;
}
`);

const { messages } = report.results[0];
const { messages } = results[0];
assert.equal(messages.length, 1);
assert.equal(messages[0].ruleId, '@lwc/lwc/valid-api');
});
Expand Down
Loading