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

Chore: lint all files in the repo at the same time #11425

Merged
merged 2 commits into from Feb 21, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 2 additions & 22 deletions Makefile.js
Expand Up @@ -63,8 +63,6 @@ const NODE = "node ", // intentional extra space
ESLINT = `${NODE} bin/eslint.js --report-unused-disable-directives `,

// Files
MAKEFILE = "./Makefile.js",
JS_FILES = "\"lib/**/*.js\" \"conf/**/*.js\" \"bin/**/*.js\" \"tools/**/*.js\"",
JSON_FILES = find("conf/").filter(fileType("json")),
MARKDOWN_FILES_ARRAY = find("docs/").concat(ls(".")).filter(fileType("md")),
TEST_FILES = getTestFilePatterns(),
Expand Down Expand Up @@ -502,14 +500,8 @@ target.lint = function() {
let errors = 0,
lastReturn;

echo("Validating Makefile.js");
lastReturn = exec(`${ESLINT} ${MAKEFILE}`);
if (lastReturn.code !== 0) {
errors++;
}

echo("Validating .eslintrc.js");
lastReturn = exec(`${ESLINT} .eslintrc.js`);
echo("Validating JavaScript files");
lastReturn = exec(`${ESLINT} .`);
if (lastReturn.code !== 0) {
errors++;
}
Expand All @@ -523,18 +515,6 @@ target.lint = function() {
errors++;
}

echo("Validating JavaScript files");
lastReturn = exec(`${ESLINT} ${JS_FILES}`);
if (lastReturn.code !== 0) {
errors++;
}

echo("Validating JavaScript test files");
lastReturn = exec(`${ESLINT} "tests/**/*.js"`);
if (lastReturn.code !== 0) {
errors++;
}

if (errors) {
exit(1);
}
Expand Down
56 changes: 35 additions & 21 deletions karma.conf.js
Expand Up @@ -9,8 +9,10 @@ module.exports = function(config) {
basePath: "",


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
/*
* frameworks to use
* available frameworks: https://npmjs.org/browse/keyword/karma-adapter
*/
frameworks: ["mocha"],


Expand All @@ -26,8 +28,10 @@ module.exports = function(config) {
],


// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
/*
* preprocess matching files before serving them to the browser
* available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
*/
preprocessors: {
"tests/lib/linter.js": ["webpack"]
},
Expand All @@ -40,9 +44,11 @@ module.exports = function(config) {
},


// test results reporter to use
// possible values: "dots", "progress"
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
/*
* test results reporter to use
* possible values: "dots", "progress"
* available reporters: https://npmjs.org/browse/keyword/karma-reporter
*/
reporters: ["mocha"],

mochaReporter: {
Expand All @@ -57,31 +63,39 @@ module.exports = function(config) {
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
/*
* level of logging
* possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
*/
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
/*
* start these browsers
* available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
*/
browsers: ["HeadlessChrome"],
customLaunchers: {
HeadlessChrome: {
base: 'ChromeHeadless',
flags: [ '--no-sandbox', ],
},
},

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
HeadlessChrome: {
base: "ChromeHeadless",
flags: ["--no-sandbox"]
}
},

/*
* Continuous Integration mode
* if true, Karma captures browsers, runs the tests and exits
*/
singleRun: true,

// Concurrency level
// how many browser should be started simultaneous
/*
* Concurrency level
* how many browser should be started simultaneous
*/
concurrency: Infinity
});
};
36 changes: 5 additions & 31 deletions packages/eslint-config-eslint/index.js
@@ -1,35 +1,9 @@
/**
* @fileoverview Converts YAML file into JSON.
* @author Nicholas C. Zakas
* @fileoverview Index file to allow YAML file to be loaded
* @author Teddy Katz
*/
"use strict";

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

var fs = require("fs"),
path = require("path"),
yaml = require("js-yaml");
not-an-aardvark marked this conversation as resolved.
Show resolved Hide resolved

//------------------------------------------------------------------------------
// Bootstrapping
//------------------------------------------------------------------------------

var filePath = path.resolve(__dirname, "./default.yml"),
config;

try {
config = yaml.safeLoad(fs.readFileSync(filePath, "utf8")) || {};
} catch (e) {
console.error(`Error reading YAML file: ${filePath}`);
e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
throw e;
}


//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

module.exports = config;
module.exports = {
extends: ["./default.yml"]
};
3 changes: 0 additions & 3 deletions packages/eslint-config-eslint/package.json
Expand Up @@ -19,9 +19,6 @@
},
"homepage": "https://eslint.org",
"bugs": "https://github.com/eslint/eslint/issues/",
"dependencies": {
"js-yaml": "^3.12.1"
},
"peerDependencies": {
"eslint-plugin-node": "^6.0.1 || ^7.0.1 || ^8.0.0"
},
Expand Down
2 changes: 2 additions & 0 deletions webpack.config.js
@@ -1,3 +1,5 @@
"use strict";

module.exports = {
mode: "none",
entry: ["@babel/polyfill", "./lib/linter.js"],
Expand Down