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

Revamp eslint configuration. #5469

Merged
merged 7 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tmp
dist
node-tests/fixtures/
blueprints/*/mocha-files/
blueprints/*/qunit-files/
blueprints/*/files/
121 changes: 82 additions & 39 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
/* global module */
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
ecmaVersion: 2017,
sourceType: 'module',
},
extends: 'eslint:recommended',
env: {
'browser': true,
},
globals: {
'heimdall': true,
'Map': false,
},
extends: ['eslint:recommended', 'prettier'],
plugins: ['prettier'],
rules: {
'prettier/prettier': 'error',

'no-unused-vars': ['error', {
'args': 'none',
}],
Expand All @@ -29,35 +24,83 @@ module.exports = {
'no-irregular-whitespace': 'error',
'no-undef': 'error',
'no-eq-null': 'error',
},
overrides: [
// node files
{
files: [
'ember-cli-build.js',
'index.js',
'testem.js',
'lib/**/*.js',
'blueprints/*/index.js',
'blueprints/*.js',
'config/**/*.js',
'tests/dummy/config/**/*.js',
'node-tests/**',
'bin/**',
],
excludedFiles: [
'addon/**',
'addon-test-support/**',
'app/**',
'tests/dummy/app/**'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true,
es6: true,
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here
})
},

// from JSCS
'array-bracket-spacing': ['error', 'never'],
'comma-style': ['error', 'last'],
'brace-style': ['error', '1tbs', {
'allowSingleLine': true,
}],
'no-spaced-func': 'error',
'no-empty': 'error',
'curly': ['error', 'all'],
'eol-last': 'error',
'no-trailing-spaces': 'error',
'comma-dangle': ['error', 'never'],
'space-before-blocks': ['error', 'always'],
'indent': ['error', 2, {
'SwitchCase': 1,
}],
'keyword-spacing': ['error', {
'overrides': {
'else': {
'before': true,
},
'while': {
'before': true,
},
'catch': {
'before': true,
},
// browser files
{
files: [
'addon/**',
'app/**',
'tests/**',
],
excludedFiles: [
'tests/dummy/config/**'
],
env: {
browser: true,
node: false,
},
}],
},
globals: {
heimdall: true,
Map: false,
}
},

// browser tests
{
files: [
'tests/**'
],

rules: {
'no-console': 0
}
},

// node tests
{
files: [
'node-tests/**'
],

env: {
mocha: true,
}
}
],
};
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ testem.js
*.gemspec
**/*.rb
node-tests/
lib/yuidoc.js
lib/version-replace.js
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = {
singleQuote: true,
trailingComma: 'es5',
printWidth: 100,
};
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
env: NAME=test # used only to make Travis UI show description
script:
- ./bin/lint-features
- yarn lint:js
- yarn test

- stage: additional tests
Expand Down
2 changes: 1 addition & 1 deletion bin/publish-builds
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ echo -e "CURRENT_BRANCH: ${TRAVIS_BRANCH}\n"
echo -e "PULL_REQUEST: ${TRAVIS_PULL_REQUEST}\n"

if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
./bin/publish-to-s3.js
node ./bin/publish-to-s3.js
fi
2 changes: 0 additions & 2 deletions bin/publish-to-s3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

// This publish script remains in order to publish the yui-docs to S3, builds no
// longer need to be published to S3.
//
Expand Down
2 changes: 0 additions & 2 deletions blueprints/adapter-test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-env node */

var testInfo = require('ember-cli-test-info');
var useTestFrameworkDetector = require('../test-framework-detector');

Expand Down
2 changes: 0 additions & 2 deletions blueprints/adapter/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-env node */

var extendFromApplicationEntity = require('../../lib/utilities/extend-from-application-entity');

module.exports = {
Expand Down
2 changes: 0 additions & 2 deletions blueprints/model-test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-env node */

var ModelBlueprint = require('../model');
var testInfo = require('ember-cli-test-info');
var useTestFrameworkDetector = require('../test-framework-detector');
Expand Down
2 changes: 0 additions & 2 deletions blueprints/model/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-env node */

var inflection = require('inflection');
var stringUtils = require('ember-cli-string-utils');
var EOL = require('os').EOL;
Expand Down
2 changes: 0 additions & 2 deletions blueprints/serializer-test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-env node */

var testInfo = require('ember-cli-test-info');
var useTestFrameworkDetector = require('../test-framework-detector');

Expand Down
2 changes: 0 additions & 2 deletions blueprints/serializer/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-env node */

var extendFromApplicationEntity = require('../../lib/utilities/extend-from-application-entity');

module.exports = {
Expand Down
2 changes: 0 additions & 2 deletions blueprints/transform-test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-env node */

var testInfo = require('ember-cli-test-info');
var useTestFrameworkDetector = require('../test-framework-detector');

Expand Down
2 changes: 0 additions & 2 deletions blueprints/transform/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-env node */

module.exports = {
description: 'Generates an ember-data value transform.'
};
2 changes: 1 addition & 1 deletion config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-env node, es6 */
'use strict';

const getChannelURL = require('ember-source-channel-url');

Expand Down
2 changes: 1 addition & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
/* eslint-env node */

const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
const merge = require('broccoli-merge-trees');
const yuidoc = require('./lib/yuidoc');
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-env node */
'use strict';

const path = require('path');
Expand Down Expand Up @@ -60,6 +59,7 @@ module.exports = {
} else if (this.ui) {
this.ui.writeLine(warning);
} else {
// eslint-disable-next-line no-console
console.log(warning);
}
},
Expand Down
10 changes: 0 additions & 10 deletions lib/.eslintrc.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/babel-build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var babel = require('broccoli-babel-transpiler');
var path = require('path');
var moduleResolve = require('amd-name-resolver').moduleResolve;

function getDebugMacroPlugins() {
Expand Down
5 changes: 3 additions & 2 deletions lib/calculate-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ module.exports = function() {
var packageVersion = package.version;
var suffix = '';

var info;
if (fs.existsSync(gitPath)) {
var info = gitRepoInfo(gitPath);
info = gitRepoInfo(gitPath);
if (info.tag) {
return info.tag.replace(/^v/, '');
}

suffix = '+' + info.sha.slice(0, 10);
} else {
var info = npmGitInfo(package);
info = npmGitInfo(package);
if (info.isInstalledAsNpmPackage() && !info.hasVersionInRef()) {
suffix = '+' + info.abbreviatedSha;
}
Expand Down
1 change: 0 additions & 1 deletion lib/enable-optional-features-via-url/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-env node */
module.exports = {
name: 'enable-optional-features-via-url',

Expand Down
1 change: 1 addition & 0 deletions lib/stripped-build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ module.exports = function(environment) {
plugins.push([StripHeimdall]);
uniqueAdd(filteredImports, 'ember-data/-debug', ['instrument']);
} else {
// eslint-disable-next-line no-console
console.warn('NOT STRIPPING HEIMDALL');
}

Expand Down
4 changes: 0 additions & 4 deletions lib/stripped-build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
var fs = require('fs');
var path = require('path');
var filterImports = require('babel-plugin-filter-imports');
var featureFlags = require('babel-plugin-feature-flags');
var babelBuild = require('./babel-build');
var strippedBuildPlugins = require('./stripped-build-plugins');

Expand Down
2 changes: 1 addition & 1 deletion lib/utilities/extend-from-application-entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function(type, baseClass, options) {
var importStatement = 'import DS from \'ember-data\';';

if (options.baseClass) {
baseClass = stringUtil.classify(options.baseClass.replace('\/', '-'));
baseClass = stringUtil.classify(options.baseClass.replace('/', '-'));
baseClass = baseClass + stringUtil.classify(type);
importStatement = 'import ' + baseClass + ' from \'' + relativePath + options.baseClass + '\';';
}
Expand Down
1 change: 0 additions & 1 deletion lib/yuidoc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var YUIDoc = require('broccoli-yuidoc');
var calculateVersion = require('./calculate-version');
var path = require('path');

module.exports = function yui() {
return new YUIDoc(['addon', 'node_modules/ember-inflector/addon'], {
Expand Down
2 changes: 2 additions & 0 deletions node-tests/nodetest-runner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

/* eslint-disable no-console, no-process-exit */

if (/^win/.test(require('os').platform())){
// don't run these tests in windows right now, they don't work
process.exit(0);
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"scripts": {
"build": "ember build",
"build:production": "ember build --environment=production",
"lint:js": "eslint .",
"start": "ember server",
"test": "ember test && ember test --record-data-rfc-build",
"test:all": "ember try:each",
Expand All @@ -22,6 +23,7 @@
"dependencies": {
"@ember/ordered-set": "^1.0.0",
"amd-name-resolver": "0.0.7",
"babel-plugin-debug-macros": "^0.1.11",
"babel-plugin-ember-modules-api-polyfill": "^1.4.2",
"babel-plugin-feature-flags": "^0.3.1",
"babel-plugin-filter-imports": "^0.3.1",
Expand Down Expand Up @@ -52,7 +54,6 @@
"silent-error": "^1.0.0"
},
"devDependencies": {
"babel-plugin-debug-macros": "^0.1.7",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"babel-plugin-transform-es2015-classes": "^6.23.0",
"babel-plugin-transform-es2015-computed-properties": "^6.22.0",
Expand All @@ -76,13 +77,12 @@
"ember-cli-app-version": "^3.0.0",
"ember-cli-blueprint-test-helpers": "^0.18.3",
"ember-cli-dependency-checker": "^2.1.0",
"ember-cli-eslint": "1.3.0",
"ember-cli-eslint": "^4.2.3",
"ember-cli-htmlbars": "^2.0.1",
"ember-cli-htmlbars-inline-precompile": "^0.4.3",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-internal-test-helpers": "^0.8.1",
"ember-cli-pretender": "^1.0.1",
"ember-qunit": "^3.4.0",
"ember-cli-release": "^0.2.9",
"ember-cli-shims": "^1.0.2",
"ember-cli-sri": "^2.1.0",
Expand All @@ -93,17 +93,22 @@
"ember-export-application-global": "^1.0.5",
"ember-load-initializers": "^0.6.0",
"ember-publisher": "0.0.7",
"ember-qunit": "^3.4.0",
"ember-qunit-assert-helpers": "^0.2.1",
"ember-resolver": "^4.1.0",
"ember-source": "~3.0.0",
"ember-source-channel-url": "^1.0.1",
"ember-try": "^0.2.23",
"ember-watson": "^0.7.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-prettier": "^2.6.0",
"github": "^1.1.1",
"glob": "^5.0.13",
"loader.js": "^4.5.0",
"mocha": "^2.4.5",
"mocha-only-detector": "0.0.2",
"prettier": "^1.12.1",
"rimraf": "2.5.2",
"rsvp": "4.8.0",
"testdouble": "^3.2.6",
Expand Down
Loading