Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial lint config for tests/blueprints #9054

Merged
merged 2 commits into from
Oct 26, 2023
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ MOCK_DATA.json
# unconventional
blueprints/
vendor/
!tests/blueprints/

# prettier is reporting syntax errors in these
*.yml
Expand Down
1 change: 1 addition & 0 deletions config/eslint/ignore.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const RULES = [
// # unconventional js
'blueprints/',
'!tests/blueprints/',
'vendor',

// # Declaration files
Expand Down
20 changes: 20 additions & 0 deletions config/eslint/mocha.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const isolation = require('./isolation.cjs');

function defaults(config = {}) {
return {
files: config.files || ['tests/**/*-test.{js,ts}'],
plugins: ['mocha'],
extends: ['plugin:mocha/recommended'],
env: {
node: true,
},
rules: {
// We use setup to set up beforeEach hooks, etc, which should be OK
'mocha/no-setup-in-describe': 'off',
},
};
}

module.exports = {
defaults,
};
1 change: 1 addition & 0 deletions config/eslint/qunit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function defaults(config = {}) {
isolation.rules({
allowedImports: ['@ember/debug', '@ember/test-helpers', 'qunit'],
}),
config?.rules,
{}
),
};
Expand Down
1 change: 1 addition & 0 deletions config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-mocha": "^10.2.0",
"eslint-plugin-n": "^16.2.0",
"eslint-plugin-qunit": "^8.0.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
Expand Down
21 changes: 21 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions tests/blueprints/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const base = require('@warp-drive/internal-config/eslint/base.cjs');
const ignore = require('@warp-drive/internal-config/eslint/ignore.cjs');
const imports = require('@warp-drive/internal-config/eslint/imports.cjs');
const isolation = require('@warp-drive/internal-config/eslint/isolation.cjs');
const mocha = require('@warp-drive/internal-config/eslint/mocha.cjs');
const node = require('@warp-drive/internal-config/eslint/node.cjs');
const parser = require('@warp-drive/internal-config/eslint/parser.cjs');
const qunit = require('@warp-drive/internal-config/eslint/qunit.cjs');

module.exports = {
...parser.defaults(),

plugins: [...base.plugins(), ...imports.plugins()],
extends: [...base.extend()],
rules: Object.assign(base.rules(), imports.rules(), isolation.rules(), {}),

ignorePatterns: ignore.ignoreRules(),

overrides: [
node.config(),
node.defaults(),
qunit.defaults({
files: ['fixtures/**/*.{js,ts}'],
rules: {
// Fixing these would cause test failures
'prefer-const': 'off',
'simple-import-sort/imports': 'off',
},
}),
mocha.defaults(),
],
};
2 changes: 2 additions & 0 deletions tests/blueprints/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"license": "MIT",
"author": "",
"scripts": {
"lint": "eslint . --quiet --cache --cache-strategy=content --ext .js,.ts,.mjs,.cjs --report-unused-disable-directives",
"test:blueprints": "mocha tests",
"_syncPnpm": "bun run sync-dependencies-meta-injected"
},
Expand Down Expand Up @@ -89,6 +90,7 @@
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@warp-drive/core-types": "workspace:5.5.0-alpha.11",
"@warp-drive/internal-config": "workspace:5.5.0-alpha.11",
"ember-cli": "~5.3.0",
"ember-cli-blueprint-test-helpers": "^0.19.2",
"ember-inflector": "^4.0.2",
Expand Down
22 changes: 11 additions & 11 deletions tests/blueprints/tests/adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

it('adapter', async function () {
let args = ['adapter', 'foo'];
const args = ['adapter', 'foo'];

await emberGenerateDestroy(args, (_file) => {
expect(_file('app/adapters/foo.js'))
Expand All @@ -40,7 +40,7 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

it('adapter extends application adapter if it exists', async function () {
let args = ['adapter', 'foo'];
const args = ['adapter', 'foo'];

await emberGenerate(['adapter', 'application']);
await emberGenerateDestroy(args, (_file) => {
Expand All @@ -53,7 +53,7 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

it('adapter with --base-class', async function () {
let args = ['adapter', 'foo', '--base-class=bar'];
const args = ['adapter', 'foo', '--base-class=bar'];

await emberGenerateDestroy(args, (_file) => {
expect(_file('app/adapters/foo.js'))
Expand All @@ -65,13 +65,13 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

xit('adapter throws when --base-class is same as name', function () {
let args = ['adapter', 'foo', '--base-class=foo'];
const args = ['adapter', 'foo', '--base-class=foo'];

return expect(emberGenerate(args)).to.be.rejectedWith(SilentError, /Adapters cannot extend from themself/);
});

it('adapter when is named "application"', function () {
let args = ['adapter', 'application'];
const args = ['adapter', 'application'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/adapters/application.js'))
Expand All @@ -85,7 +85,7 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

it('adapter-test', function () {
let args = ['adapter-test', 'foo'];
const args = ['adapter-test', 'foo'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('tests/unit/adapters/foo-test.js')).to.equal(fixture(__dirname, 'adapter-test/rfc232.js'));
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

it('adapter', function () {
let args = ['adapter', 'foo'];
const args = ['adapter', 'foo'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/adapters/foo.js'))
Expand All @@ -130,7 +130,7 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

it('adapter extends application adapter if it exists', function () {
let args = ['adapter', 'foo'];
const args = ['adapter', 'foo'];

return emberGenerate(['adapter', 'application']).then(() =>
emberGenerateDestroy(args, (_file) => {
Expand All @@ -144,7 +144,7 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

it('adapter with --base-class', function () {
let args = ['adapter', 'foo', '--base-class=bar'];
const args = ['adapter', 'foo', '--base-class=bar'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/adapters/foo.js'))
Expand All @@ -156,7 +156,7 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

it('adapter when is named "application"', function () {
let args = ['adapter', 'application'];
const args = ['adapter', 'application'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/adapters/application.js'))
Expand All @@ -170,7 +170,7 @@ describe('Acceptance: generate and destroy adapter blueprints', function () {
});

it('adapter-test', function () {
let args = ['adapter-test', 'foo'];
const args = ['adapter-test', 'foo'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('tests/unit/adapters/foo-test.js')).to.equal(fixture(__dirname, 'adapter-test/rfc232.js'));
Expand Down
20 changes: 10 additions & 10 deletions tests/blueprints/tests/model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model', function () {
let args = ['model', 'foo'];
const args = ['model', 'foo'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/models/foo.js'))
Expand All @@ -38,7 +38,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model with attrs', function () {
let args = [
const args = [
'model',
'foo',
'misc',
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model with belongsTo', function () {
let args = ['model', 'comment', 'post:belongs-to', 'author:belongs-to:user'];
const args = ['model', 'comment', 'post:belongs-to', 'author:belongs-to:user'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/models/comment.js'))
Expand All @@ -85,7 +85,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model with hasMany', function () {
let args = ['model', 'post', 'comments:has-many', 'otherComments:has-many:comment'];
const args = ['model', 'post', 'comments:has-many', 'otherComments:has-many:comment'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/models/post.js'))
Expand All @@ -99,7 +99,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model-test', function () {
let args = ['model-test', 'foo'];
const args = ['model-test', 'foo'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('tests/unit/models/foo-test.js')).to.equal(fixture(__dirname, 'model-test/rfc232.js'));
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model', function () {
let args = ['model', 'foo'];
const args = ['model', 'foo'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/models/foo.js'))
Expand All @@ -144,7 +144,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model with attrs', function () {
let args = [
const args = [
'model',
'foo',
'misc',
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model with belongsTo', function () {
let args = ['model', 'comment', 'post:belongs-to', 'author:belongs-to:user'];
const args = ['model', 'comment', 'post:belongs-to', 'author:belongs-to:user'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/models/comment.js'))
Expand All @@ -191,7 +191,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model with hasMany', function () {
let args = ['model', 'post', 'comments:has-many', 'otherComments:has-many:comment'];
const args = ['model', 'post', 'comments:has-many', 'otherComments:has-many:comment'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('app/models/post.js'))
Expand All @@ -205,7 +205,7 @@ describe('Acceptance: generate and destroy model blueprints', function () {
});

it('model-test', function () {
let args = ['model-test', 'foo'];
const args = ['model-test', 'foo'];

return emberGenerateDestroy(args, (_file) => {
expect(_file('tests/unit/models/foo-test.js')).to.equal(fixture(__dirname, 'model-test/rfc232.js'));
Expand Down
Loading